-
Notifications
You must be signed in to change notification settings - Fork 2
Introduction
EMT edited this page Dec 26, 2024
·
1 revision
[CreateAssetMenu(menuName = "Emilia/Examples/Test")]
public class TestAsset : EditorUniversalGraphAsset { }
public abstract class TestBaseNodeAsset : UniversalNodeAsset { }
public abstract class TestBaseNode : UniversalEditorNodeView { }
//TestNodeAsset是继承ScriptableObject的需要单独一个文件并且文件名和类名匹配
[NodeMenu("测试节点")]
public class TestNodeAsset : UniversalNodeAsset { }
[EditorNode(typeof(TestNodeAsset))]
public class TestNode : UniversalEditorNodeView { }
给编辑器文件添加特性NodeToEditor
[CreateAssetMenu(menuName = "Emilia/Examples/Test"), NodeToEditor(typeof(TestNodeAsset))]
public class TestAsset : EditorGraphAsset { }
完成上述步骤 右键菜单CrateNode可以创建刚刚写的测试节点
[EditorNode(typeof(TestNodeAsset))]
public class TestNode : TestBaseNode
{
public override List<EditorPortInfo> CollectStaticPortAssets()
{
List<EditorPortInfo> portAssets = new List<EditorPortInfo>();
EditorPortInfo inputPort = new EditorPortInfo();
inputPort.id = "Input";
inputPort.direction = EditorPortDirection.Input;
portAssets.Add(inputPort);
EditorPortInfo outputPort = new EditorPortInfo();
outputPort.id = "Output";
outputPort.direction = EditorPortDirection.Output;
portAssets.Add(outputPort);
return portAssets;
}
}