void Initialize() { RegisterCallback <KeyDownEvent>(KeyCallback); processor = MixtureGraphProcessor.GetOrCreate(graph); computeOrderUpdated += () => { processor.UpdateComputeOrder(); UpdateNodeColors(); }; graph.onOutputTextureUpdated += () => ProcessGraph(); graph.onGraphChanges += _ => { this.schedule.Execute(() => ProcessGraph()).ExecuteLater(10); MarkDirtyRepaint(); }; // Run the processor when we open the graph ProcessGraph(); }
void Initialize() { RegisterCallback <KeyDownEvent>(KeyCallback); processor = MixtureGraphProcessor.GetOrCreate(graph); computeOrderUpdated += () => { processor.UpdateComputeOrder(); UpdateNodeColors(); }; graph.onOutputTextureUpdated += () => ProcessGraph(); graph.onGraphChanges -= ProcessGraphWhenChanged; graph.onGraphChanges += ProcessGraphWhenChanged; // Run the processor when we open the graph ProcessGraph(); SetupRepaintChecker(); }
void Initialize() { RegisterCallback <KeyDownEvent>(KeyCallback); processor = MixtureGraphProcessor.GetOrCreate(graph); computeOrderUpdated += () => { processor.UpdateComputeOrder(); UpdateNodeColors(); }; graph.onOutputTextureUpdated += () => ProcessGraph(); bool delayQueued = false; graph.onGraphChanges += ProcessGraphWhenChanged; // Run the processor when we open the graph ProcessGraph(); void ProcessGraphWhenChanged(GraphChanges changes) { if (delayQueued) { return; } if (changes.addedEdge != null || changes.removedEdge != null || changes.addedNode != null || changes.removedNode != null || changes.nodeChanged != null) { EditorApplication.update += DelayedProcess; void DelayedProcess() { ProcessGraph(changes.nodeChanged ?? changes.addedNode); MarkDirtyRepaint(); delayQueued = false; EditorApplication.update -= DelayedProcess; } delayQueued = true; } } }