Skip to content

Graph Editors

Thor Brigsted edited this page Sep 4, 2018 · 18 revisions

Example

[CustomNodeGraphEditor(typeof(MyGraph))]
public class MyGraphEditor : NodeGraphEditor {

}

Repaint each frame

Sometimes you may want your nodes to repaint every frame. This is achievable though spamming 'repaint me' in OnGUI. don't worry, it won't freeze :)

public override void OnGUI() {
    // Keep repainting the GUI of the active NodeEditorWindow
    NodeEditorWindow.current.Repaint();
}

Store preferences specific to your node graph or project

  1. Add a unique EditorPrefs key to the attribute
[CustomNodeGraphEditor(typeof(MyGraph), "MyGraph.Settings")]
  1. Override GetDefaultPreferences(); to set default preferences
public override NodeEditorPreferences.Settings GetDefaultPreferences() {
    return new NodeEditorPreferences.Settings() {
        gridBgColor = Color.black,
        gridLineColor = Color.white,
        typeColors = new Dictionary<string, Color>() {
            { typeof(string).PrettyName(), Color.yellow },
            { typeof(MyType).PrettyName(), new Color(1,0.5f,0.6f) }
        }
    };
}
Clone this wiki locally