GetSizeOfMainGameView changed signature?


I use an asset that detects the size of the game view. It uses the code below. That does work in 5.3 but not in 5.4b1 anymore. I played a bit but could not figure out the correct signature. I guess it changed due to the zoomable additions. What would the new code need to look like now?

System.Type T = System.Type.GetType("UnityEditor.GameView, UnityEditor");
System.Reflection.MethodInfo GetSizeOfMainGameView = T.GetMethod ("GetSizeOfMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
System.Object Res = GetSizeOfMainGameView.Invoke (null,null);
return (Vector2) Res;

The third line will throw the error: "NullReferenceException: Object reference not set to an instance of an object"

got same problem, I found this

2441932--167469--Cap 2015-12-29 17-10-56-470.png

Were you able to fix it yet? If so, could you post the code please?

That function was replaced by

internal static Vector2 GetMainGameViewTargetSize()

Internal methods are not officially supported, and (as you've just seen) may change or disappear without warning in any version of Unity.

1 Like