Author Topic: Error with s_GetSizeOfMainGameView.Invoke in 5.4.0b9  (Read 4533 times)

col000r

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 43
  • Mighty Emperor of Planet "Home Office"
    • View Profile
    • BLACKISH
Error with s_GetSizeOfMainGameView.Invoke in 5.4.0b9
« on: March 11, 2016, 08:27:09 AM »
Getting this error in the latest beta (5.4.0b9):

  1. NullReferenceException: Object reference not set to an instance of an object
  2. NGUITools.get_screenSize () (at Assets/NGUI/Scripts/Internal/NGUITools.cs:1871)
  3. UIPanel.GetViewSize () (at Assets/NGUI/Scripts/UI/UIPanel.cs:1871)
  4. UIPanel.UpdateTransformMatrix () (at Assets/NGUI/Scripts/UI/UIPanel.cs:1068)
  5. UIPanel.UpdateSelf () (at Assets/NGUI/Scripts/UI/UIPanel.cs:1265)
  6. UIPanel.LateUpdate () (at Assets/NGUI/Scripts/UI/UIPanel.cs:1228)

and that points me to:

  1. mGameSize = (Vector2)s_GetSizeOfMainGameView.Invoke(null, null);

I see you're using reflection there to call some unity code. Did they change or rename that function?
Can you fix this please?
Games: BLACKISH | Blog | Assets

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error with s_GetSizeOfMainGameView.Invoke in 5.4.0b9
« Reply #1 on: March 12, 2016, 07:43:10 AM »
It's been fixed in NGUI pro for weeks now, and Unity actually re-added the function on their end in order to accomodate those that are not able to update NGUI due to being midway through a project.

In short, already fixed, you'll see it in the next update.
  1.         static public Vector2 screenSize
  2.         {
  3.                 get
  4.                 {
  5.                         int frame = Time.frameCount;
  6.  
  7.                         if (mSizeFrame != frame || !Application.isPlaying)
  8.                         {
  9.                                 mSizeFrame = frame;
  10.  
  11.                                 if (s_GetSizeOfMainGameView == null)
  12.                                 {
  13.                                         System.Type type = System.Type.GetType("UnityEditor.GameView,UnityEditor");
  14.  
  15.                                         // Pre-Unity 5.4
  16.                                         s_GetSizeOfMainGameView = type.GetMethod("GetSizeOfMainGameView",
  17.                                                 System.Reflection.BindingFlags.Public |
  18.                                                 System.Reflection.BindingFlags.NonPublic |
  19.                                                 System.Reflection.BindingFlags.Static);
  20.  
  21.                                         // Post-Unity 5.4
  22.                                         if (s_GetSizeOfMainGameView == null)
  23.                                                 s_GetSizeOfMainGameView = type.GetMethod("GetMainGameViewTargetSize",
  24.                                                         System.Reflection.BindingFlags.Public |
  25.                                                         System.Reflection.BindingFlags.NonPublic |
  26.                                                         System.Reflection.BindingFlags.Static);
  27.                                 }
  28.  
  29.                                 if (s_GetSizeOfMainGameView != null)
  30.                                 {
  31.                                         mGameSize = (Vector2)s_GetSizeOfMainGameView.Invoke(null, null);
  32.                                 }
  33.                                 else mGameSize = new Vector2(Screen.width, Screen.height);
  34.                         }
  35.                         return mGameSize;
  36.                 }
  37.         }