Added Maz Nodes
This commit is contained in:
parent
7fcd596a16
commit
a17b04566e
58
Editor/Scripts/Editor/Nodes/Types/String/DebugLogNode.cs
Normal file
58
Editor/Scripts/Editor/Nodes/Types/String/DebugLogNode.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System.IO;
|
||||||
|
using AssetGraph.Core;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using AssetGraph.Core.Attributes;
|
||||||
|
using AssetGraph.Nodes;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||||
|
{
|
||||||
|
[NodeInfo("Debug Log", "Debug/Debug Log", editorType: typeof(DebugLogNodeEditor))]
|
||||||
|
public class DebugLogNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("Log Text")]
|
||||||
|
public string logText;
|
||||||
|
|
||||||
|
public delegate void OnNodeUpdated();
|
||||||
|
public OnNodeUpdated onNodeUpdated;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
Debug.Log(logText);
|
||||||
|
onNodeUpdated?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DebugLogNodeEditor : AssetGraphNodeEditor
|
||||||
|
{
|
||||||
|
DebugLogNode logNode;
|
||||||
|
Label label;
|
||||||
|
|
||||||
|
public DebugLogNodeEditor(AssetGraphNode node, AssetGraphViewWindow window) : base(node, window)
|
||||||
|
{
|
||||||
|
logNode = node as DebugLogNode;
|
||||||
|
logNode.onNodeUpdated += UpdateEditor;
|
||||||
|
label = new Label();
|
||||||
|
label.style.flexGrow = 1;
|
||||||
|
label.style.flexShrink = 1;
|
||||||
|
label.style.paddingBottom = label.style.paddingTop = label.style.paddingLeft = label.style.paddingRight = 6;
|
||||||
|
label.style.backgroundColor = new Color(0.24705f, 0.24705f, 0.24705f, 0.8039216f);
|
||||||
|
label.style.whiteSpace = WhiteSpace.Normal;
|
||||||
|
|
||||||
|
VisualElement bar = new VisualElement();
|
||||||
|
bar.name = "divider";
|
||||||
|
bar.AddToClassList("horizontal");
|
||||||
|
|
||||||
|
var contents = this.Q("contents");
|
||||||
|
|
||||||
|
contents.Add(bar);
|
||||||
|
contents.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateEditor()
|
||||||
|
{
|
||||||
|
label.text = logNode.logText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ee2323729ea6fa84788137af3807d8b7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
26
Editor/Scripts/Editor/Nodes/Types/String/ImportTextNode.cs
Normal file
26
Editor/Scripts/Editor/Nodes/Types/String/ImportTextNode.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System.IO;
|
||||||
|
using AssetGraph.Core.Attributes;
|
||||||
|
using AssetGraph.Nodes;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||||
|
{
|
||||||
|
[NodeInfo("Import Text", "Imports/Import Text")]
|
||||||
|
public class ImportTextNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("File Name")]
|
||||||
|
public string fileName;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Input("Directory")]
|
||||||
|
public string directory;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Text")]
|
||||||
|
public string outputText;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
outputText = File.ReadAllText(Path.Combine(directory, fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 455f8a7df4c9c2e4691f68b537e29573
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,25 @@
|
|||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using AssetGraph.Core.Attributes;
|
||||||
|
using AssetGraph.Nodes;
|
||||||
|
|
||||||
|
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||||
|
{
|
||||||
|
[NodeInfo("Create Directory", "Directory/Create Directory")]
|
||||||
|
public class CreateDirectoryNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("Directory")] public string inputDirectory;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Directory")] public string outputDirectory;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(inputDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(inputDirectory);
|
||||||
|
}
|
||||||
|
outputDirectory = inputDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a32e947621c08940b8f9c68c3bc0bdc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
62
Editor/Scripts/Editor/Nodes/Types/Utils/CreatePrefabNode.cs
Normal file
62
Editor/Scripts/Editor/Nodes/Types/Utils/CreatePrefabNode.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using AssetGraph.Core.Attributes;
|
||||||
|
using AssetGraph.Nodes;
|
||||||
|
|
||||||
|
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||||
|
{
|
||||||
|
[NodeInfo("Create Prefab", "Prefab/Create")]
|
||||||
|
public class CreatePrefabNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("Prefab Name")]
|
||||||
|
public string prefabName;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Input("Directory")]
|
||||||
|
public string directory;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Input("")]
|
||||||
|
public Mesh mesh;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Input("Submesh Count")]
|
||||||
|
public int submeshCount = 1;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Input("")]
|
||||||
|
public Material material;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Prefab")]
|
||||||
|
public GameObject prefab;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
GameObject newGO = new GameObject(prefabName);
|
||||||
|
var prefabPath = Path.Combine(directory, $"{prefabName}.prefab");
|
||||||
|
PrefabUtility.SaveAsPrefabAsset(newGO, prefabPath);
|
||||||
|
Object.DestroyImmediate(newGO);
|
||||||
|
|
||||||
|
using (var editScope = new PrefabUtility.EditPrefabContentsScope(prefabPath))
|
||||||
|
{
|
||||||
|
var root = editScope.prefabContentsRoot;
|
||||||
|
var meshRenderer = root.AddComponent<MeshRenderer>();
|
||||||
|
var meshFilter = root.AddComponent<MeshFilter>();
|
||||||
|
meshFilter.sharedMesh = mesh;
|
||||||
|
if (submeshCount > 1)
|
||||||
|
{
|
||||||
|
Material[] materials = new Material[submeshCount];
|
||||||
|
for (int i = 0; i < submeshCount; i++)
|
||||||
|
{
|
||||||
|
materials[i] = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
meshRenderer.sharedMaterials = materials;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meshRenderer.sharedMaterial = material;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 851727f1cfe10de4b8073aa6a334518c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
69
Editor/Scripts/Editor/Nodes/Types/Utils/ModelImportNode.cs
Normal file
69
Editor/Scripts/Editor/Nodes/Types/Utils/ModelImportNode.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System.IO;
|
||||||
|
using AssetGraph.Core.Attributes;
|
||||||
|
using AssetGraph.Nodes;
|
||||||
|
using ImageProcessingGraph.Editor;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||||
|
{
|
||||||
|
[NodeInfo("Model Import", "Imports/Import Model", true)]
|
||||||
|
public class ModelImportNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("Model")]
|
||||||
|
public GameObject modelImport;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("")]
|
||||||
|
public Mesh mesh;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("")]
|
||||||
|
public Material material;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Model Name")]
|
||||||
|
public string modelName;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Directory")]
|
||||||
|
public string directory;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
var modelPath = AssetDatabase.GetAssetPath(modelImport);
|
||||||
|
var allAssets = AssetDatabase.LoadAllAssetsAtPath(modelPath);
|
||||||
|
|
||||||
|
material = null;
|
||||||
|
mesh = null;
|
||||||
|
foreach (var asset in allAssets)
|
||||||
|
{
|
||||||
|
if (material && mesh) break;
|
||||||
|
|
||||||
|
if (!material && asset is Material foundMaterial)
|
||||||
|
{
|
||||||
|
material = foundMaterial;
|
||||||
|
}
|
||||||
|
if (!mesh && asset is Mesh foundMesh)
|
||||||
|
{
|
||||||
|
mesh = foundMesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelName = modelImport.name;
|
||||||
|
directory = Path.GetDirectoryName(modelPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[NodeInfo("Mesh Info", "Mesh/Mesh Info", true)]
|
||||||
|
public class MeshInfo : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("")]
|
||||||
|
public Mesh mesh;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Submeshes")]
|
||||||
|
public int submeshes;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
submeshes = mesh.subMeshCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 612cfa8fb6e00e14d9f78091cb61cdde
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
60
Editor/Scripts/Editor/Nodes/Types/Utils/ObjectGetNameNode.cs
Normal file
60
Editor/Scripts/Editor/Nodes/Types/Utils/ObjectGetNameNode.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using System.IO;
|
||||||
|
using AssetGraph.Core.Attributes;
|
||||||
|
using AssetGraph.Nodes;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace ImageProcessingGraph.Editor.Nodes.MazStuff
|
||||||
|
{
|
||||||
|
[NodeInfo("Material Get Name", "Material/Material Get Name")]
|
||||||
|
public class MaterialGetNameNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("")] public Material inputObject;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
objectName = inputObject.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NodeInfo("Mesh Get Name", "Mesh/Mesh Get Name")]
|
||||||
|
public class MeshGetNameNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("")] public Mesh inputObject;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
objectName = inputObject.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NodeInfo("Texture Get Name", "Texture/Texture Get Name")]
|
||||||
|
public class TextureGetNameNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("")] public Texture2D inputObject;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
objectName = inputObject.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NodeInfo("GameObject Get Name", "GameObject/GameObject Get Name")]
|
||||||
|
public class GameObjectGetNameNode : AssetGraphNode
|
||||||
|
{
|
||||||
|
[AssetGraph.Core.Attributes.Input("")] public GameObject inputObject;
|
||||||
|
|
||||||
|
[AssetGraph.Core.Attributes.Output("Name")] public string objectName;
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
objectName = inputObject.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 79f6818ae71efcd48a44d3fb422891bb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user