Creating your own node views
Once you've created your own node, you can create your own node view for it. By creating a node view for your custom node, you can add additional elements to display in the graph editor.
For example, you can add a preview image, like a lot of the built-in nodes have.
Here's how you create a custom node view:
using InsaneScatterbrain.ScriptGraph.Editor;
using UnityEditor.UIElements;
// Adding this attribute tells Map Graph that this class is a node view for nodes of type ExampleNode
[ScriptNodeView(typeof(ExampleNode))]
public class ExampleNodeView : ScriptNodeView
{
public ExampleNodeView(ExampleNode node, ScriptGraphView graphView) : base(node, graphView)
{
// Here you can add UI elements to the view node.
var label = new Label("Hello, Node View!");
mainContainer.Add(label);
// This is how to easily add a preview image to your node.
// The callback should return the Texture2D that the preview image will display each time the node is processed.
this.AddPreview<ExampleNode>(GetPreviewTexture);
}
private Texture2D GetPreviewTexture(ExampleNode node) => node.TextureData.ToTexture2D();
}