示例#1
0
 public static int GetActiveSceneIndex()
 {
     if (IsBoneworks)
     {
         if (BoneworksSceneManager_currentSceneIndex == null)
         {
             BoneworksSceneManager_currentSceneIndex = NET_SDK.SDK.GetClass("StressLevelZero.Utilities.BoneworksSceneManager")?.GetField("currentSceneIndex");
         }
         if (BoneworksSceneManager_currentSceneIndex == null)
         {
             return(-9);
         }
         return(BoneworksSceneManager_currentSceneIndex.GetValue().UnboxValue <int>());
     }
     else
     {
         if (SceneManager_GetActiveScene == null)
         {
             SceneManager_GetActiveScene = NET_SDK.SDK.GetClass("UnityEngine.SceneManagement.SceneManager")?.GetMethod("GetActiveScene");
         }
         if (SceneManager_GetActiveScene == null)
         {
             return(-9);
         }
         if (Scene_buildIndex_get == null)
         {
             Scene_buildIndex_get = NET_SDK.SDK.GetClass("UnityEngine.SceneManagement.Scene")?.GetProperty("buildIndex")?.GetGetMethod();
         }
         if (Scene_buildIndex_get == null)
         {
             return(-9);
         }
         NET_SDK.Reflection.IL2CPP_Object scene = SceneManager_GetActiveScene.Invoke();
         if (scene == null)
         {
             return(-9);
         }
         NET_SDK.Reflection.IL2CPP_Object buildIndex = Scene_buildIndex_get.Invoke(scene);
         if (buildIndex == null)
         {
             return(-9);
         }
         return(buildIndex.UnboxValue <int>());
     }
 }
示例#2
0
 private static void VRChat_CheckUiManager()
 {
     if (IsInitialized && ShouldCheckForUiManager)
     {
         if (VRCUiManager == null)
         {
             VRCUiManager = NET_SDK.SDK.GetClass("VRCUiManager");
         }
         if (VRCUiManager != null)
         {
             if (VRCUiManager_GetInstance == null)
             {
                 NET_SDK.Reflection.IL2CPP_Method[] methods = VRCUiManager.GetMethods();
                 foreach (NET_SDK.Reflection.IL2CPP_Method method in methods)
                 {
                     NET_SDK.Reflection.IL2CPP_Type returntype = method.GetReturnType();
                     if ((returntype != null) && !string.IsNullOrEmpty(returntype.Name) && returntype.Name.Equals("VRCUiManager"))
                     {
                         if (method.HasFlag(NET_SDK.Reflection.IL2CPP_BindingFlags.METHOD_STATIC))
                         {
                             VRCUiManager_GetInstance = method;
                             break;
                         }
                     }
                 }
             }
             if (VRCUiManager_GetInstance != null)
             {
                 NET_SDK.Reflection.IL2CPP_Object returnval = VRCUiManager_GetInstance.Invoke();
                 if (returnval != null)
                 {
                     ShouldCheckForUiManager = false;
                     if (Mods.Count() > 0)
                     {
                         foreach (MelonMod mod in Mods)
                         {
                             try { mod.VRChat_OnUiManagerInit(); } catch (Exception ex) { MelonModLogger.LogModError(ex.ToString(), mod.InfoAttribute.Name); }
                         }
                     }
                 }
             }
         }
     }
 }