Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Scripting GetSizeOfMainGameView changed signature?

Discussion in '5.4 Beta' started by ImpossibleRobert, Dec 28, 2015.

  1. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    530
    Hi,

    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?


    Code (CSharp):
    1. System.Type T = System.Type.GetType("UnityEditor.GameView, UnityEditor");
    2. System.Reflection.MethodInfo GetSizeOfMainGameView = T.GetMethod ("GetSizeOfMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
    3. System.Object Res = GetSizeOfMainGameView.Invoke (null,null);
    4. return (Vector2) Res;
    The third line will throw the error: "NullReferenceException: Object reference not set to an instance of an object"
     
  2. cycle277

    cycle277

    Joined:
    Dec 23, 2013
    Posts:
    2
    got same problem, I found this
     

    Attached Files:

  3. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    530
    Were you able to fix it yet? If so, could you post the code please?
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    That function was replaced by
    Code (CSharp):
    1. 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.
     
    Roman-Ilyin likes this.