Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    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:
    472
    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:
    472
    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.