From b2a90c832fca4d19768879a9daca1dbeda890b0e Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Fri, 14 Aug 2020 16:19:39 +1000 Subject: [PATCH] 1.3.3 Fix scene change buttons not actually working properly. --- src/CppExplorer.cs | 3 +- src/MainMenu/Pages/ConsolePage.cs | 4 +-- src/MainMenu/Pages/ScenePage.cs | 59 +++++++++++++------------------ 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/CppExplorer.cs b/src/CppExplorer.cs index 8385404..8a74d48 100644 --- a/src/CppExplorer.cs +++ b/src/CppExplorer.cs @@ -8,6 +8,7 @@ using MelonLoader; using UnhollowerBaseLib; using UnhollowerRuntimeLib; using Harmony; +using Il2CppSystem.Runtime.InteropServices; namespace Explorer { @@ -16,7 +17,7 @@ namespace Explorer // consts public const string ID = "com.sinai.cppexplorer"; - public const string VERSION = "1.3.2"; + public const string VERSION = "1.3.3"; public const string AUTHOR = "Sinai"; #if Release_Unity2018 diff --git a/src/MainMenu/Pages/ConsolePage.cs b/src/MainMenu/Pages/ConsolePage.cs index cee0eef..e21abbb 100644 --- a/src/MainMenu/Pages/ConsolePage.cs +++ b/src/MainMenu/Pages/ConsolePage.cs @@ -146,11 +146,11 @@ MelonLogger.Log(""hello world"");"; GUILayout.BeginHorizontal(null); GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(110) }); UsingInput = GUILayout.TextField(UsingInput, new GUILayoutOption[] { GUILayout.Width(150) }); - if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(50) })) + if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(120) })) { AddUsing(UsingInput); } - if (GUILayout.Button("Reset", null)) + if (GUILayout.Button("Clear All", new GUILayoutOption[] { GUILayout.Width(120) })) { ResetConsole(); } diff --git a/src/MainMenu/Pages/ScenePage.cs b/src/MainMenu/Pages/ScenePage.cs index ae256af..e5f3229 100644 --- a/src/MainMenu/Pages/ScenePage.cs +++ b/src/MainMenu/Pages/ScenePage.cs @@ -21,7 +21,6 @@ namespace Explorer // gameobject list private Transform m_currentTransform; private List m_objectList = new List(); - private float m_timeOfLastUpdate = -1f; // search bar private bool m_searching = false; @@ -45,14 +44,6 @@ namespace Explorer public override void Update() { - if (Time.time - m_timeOfLastUpdate < 0.2f) - { - return; - } - m_timeOfLastUpdate = Time.time; - - var start = Time.realtimeSinceStartup; - if (!m_searching) { m_objectList = new List(); @@ -101,33 +92,39 @@ namespace Explorer GUILayout.BeginHorizontal(null); // Current Scene label GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) }); - if (SceneManager.sceneCount > 1) + try { - int changeWanted = 0; - if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) })) + // Need to do 'ToList()' so the object isn't cleaned up by Il2Cpp GC. + var scenes = SceneManager.GetAllScenes().ToList(); + + if (scenes.Count > 1) { - changeWanted = -1; - } - if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) })) - { - changeWanted = 1; - } - if (changeWanted != 0) - { - var scenes = SceneManager.GetAllScenes(); - int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene)); - index += changeWanted; - if (index >= scenes.Count - 1) + int changeWanted = 0; + if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) })) { - index = 0; + changeWanted = -1; } - else if (index > 0) + if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) })) { - index = scenes.Count - 1; + changeWanted = 1; + } + if (changeWanted != 0) + { + int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene)); + index += changeWanted; + if (index > scenes.Count - 1) + { + index = 0; + } + else if (index < 0) + { + index = scenes.Count - 1; + } + m_currentScene = scenes[index].name; } - m_currentScene = scenes[index].name; } } + catch { } GUILayout.Label("" + m_currentScene + "", null); //new GUILayoutOption[] { GUILayout.Width(250) }); GUILayout.EndHorizontal(); @@ -169,17 +166,11 @@ namespace Explorer if (m_objectList.Count > 0) { - var start = Time.realtimeSinceStartup; foreach (var obj in m_objectList) { //UIStyles.GameobjButton(obj, SetTransformTarget, true, MainMenu.MainRect.width - 170); UIStyles.FastGameobjButton(obj.RefGameObject, obj.EnabledColor, obj.Label, obj.RefGameObject.activeSelf, SetTransformTarget, true, MainMenu.MainRect.width - 170); } - var diff = Time.realtimeSinceStartup - start; - } - else - { - // if m_currentTransform != null ... } } else // ------ Scene Search results ------