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
2k stars 415 forks source link

[Solved] Context menu not showing up. #187

Closed Vosheck closed 4 years ago

Vosheck commented 4 years ago

After customizing the rect and position of the RTNodeEditor from the examples package, the context menu wasn't showing up anymore. Turns out that GUIScaleUtility.GUIToScreenSpace on line 396 of OverlayGUI.cs was spawning the context menu at some alien looking position(-8900,-9000). Issue was solved by commenting out the GUIScaleUtility.GUIToScreenSpace part, and having the popup.Show (Event.current.mousePosition);

Seneral commented 4 years ago

That is required only in the runtime node editor when you call the node editor nested in other rects. In the RTNodeEditor.cs, add GUI.BeginGroup(new Rect(200, 0, Screen.width-200, Screen.height)); and GUI.EndGroup(); right when OverlayGUI is started/ended and you'll know what I mean. However, I removed this call completely in a recent update since I wanted to remove complexity, and failed to realize this breaks the code. There has to be at least one root rect in playmode. Has to do with the internals of the GUI system, kind of forgot the details over the years. The (-9000,-9000) is unitys absolute top-level group. Also, I might be wrong, but in previous versions of unity that was also required for the editor window, because of the way they handled the toolbar. But since calling the NodeEditor in a nested GUI setup at runtime is basically guaranteed for runtime uses, I'll have to keep it.

Pushing a fix now

Seneral commented 4 years ago

Fixed in f82311c