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

GUIScaleUtility.cs Init Method NullReferenceException in Unity 2019.1.2f1 #182

Closed JingFengJi closed 4 years ago

JingFengJi commented 4 years ago

I am trying to use Node_Editor in Unity2019.1.2f1, When I open the Node Editor, it always report a Null Error. I found that in the Init function in the GUIScaleUtility script, the topmostRect variable is empty, and its GetGetMethod returns null.

topmostRect is private in Unity 2019.1.2f1. it should be : PropertyInfo topmostRect = GUIClipType.GetProperty ("topmostRect", BindingFlags.Static | BindingFlags.NonPublic);

topmostRectDelegate = (Func<Rect>)Delegate.CreateDelegate (typeof(Func<Rect>), topmostRect.GetGetMethod (true));

Seneral commented 4 years ago

Will download 2019 now and test, but topmostRect is already searched using Public | NonPublic which should include both.

Seneral commented 4 years ago

Ok in the latest version it works fine, and the changes you propose are already there (+backwards compability), so you might be using an older version I assume?

JingFengJi commented 4 years ago

I haven't tested it with another version, just in Unity2019.1.2f1, I tested other versions.

JingFengJi commented 4 years ago

I still have this problem on Unity2019.1.12f1. I have not installed the updated version locally. Do you need me to help with more tests?

JingFengJi commented 4 years ago

image

Seneral commented 4 years ago

But are you using the latest version of the Framework from the develop branch? These are the most current lines from the develop branch and they should work just fine on your system if the lines your provide work:

PropertyInfo topmostRect = GUIClipType.GetProperty ("topmostRect", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); // ERROR

MethodInfo GetTopmostRect = topmostRect != null? (topmostRect.GetGetMethod(false) ?? topmostRect.GetGetMethod(true)) : null;

topmostRectDelegate = (Func)Delegate.CreateDelegate (typeof(Func), GetTopmostRect);

Seneral commented 4 years ago

And are you on Mac by any chance? The 'comability mode' was initially introduced because some Mac users had similar problems, but I've never been able to debug them properly It works fine on 2019.1.14f1 on Linux

JingFengJi commented 4 years ago

Sorry, I am using the code of the master branch, I switch the branch.

JingFengJi commented 4 years ago

No problem, it’s my negligence, sorry again, respected author

Seneral commented 4 years ago

Ah ok, is there any reason for that? Made the develop branch the default, master hasn't been updated in ages now. I currently don't have enough time to keep it updated regularily with fixes. Cool, no problem, glad it works now!