Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2.01k stars 414 forks source link

RTCanvasCalculator #92

Closed rc1 closed 8 years ago

rc1 commented 8 years ago

RTCanvasCalculator.cs creates all the node whenever it calculates a canvas. So if it calculates every frame there's a significant drop in framerate.

What's the proper way to calculate a canvas at runtime?

Seneral commented 8 years ago

What do you mean with 'Creates all the nodes whenever it calculates'? There is no copy made or anything, it is directly accessing the asset and performs the calculation on it. Or is this related to the debug that automatically gets called, in which case remove it if you don't need it, it wasn't meant to be called each frame and debug it anyways;) Please clarify this, thanks!

rc1 commented 8 years ago

Steps to recreate:

  1. Add the RTCanvasCalculator component to a GameObject
  2. Add a canvas to it
  3. Add a Debug.Log in a Node's Create method
  4. Call CalculateCanvas on every frame

The Debug.Log will be called every frame.

RuntimeNodeEditor doesn't do this. I've tried to pick it apart... but just get lost in this.

Seneral commented 8 years ago

Oh, ok so without trying I now know why. It is caused by #72, basically one node of each type is created on initiation, which is in the end bad design but I chose so when I first started this project to be able to overwrite the Create method for each node type (not possible with statics). Hard to overcome but that's the root cause. The problem that is most noticeable here is then caused by a different problem that is easier to fix. Node initiation consists of two parts, normal and GUI-related initiation, where GUI related initiation can only be called from OnGUI. When using the framework, it is initiating but as it wasn't called in GUI code it can't initiate the GUI, and currently that means it is still flagged as not initiated. So that's why a call to the framework each frame currently causes it to re-initiate each frame. I'll fix it and report back:)

rc1 commented 8 years ago

Great. Thanks

Seneral commented 8 years ago

Fixed in 786a804 :)