Fix scene change buttons not actually working properly.
This commit is contained in:
sinaioutlander 2020-08-14 16:19:39 +10:00
parent 9a784fd467
commit b2a90c832f
3 changed files with 29 additions and 37 deletions

View File

@ -8,6 +8,7 @@ using MelonLoader;
using UnhollowerBaseLib; using UnhollowerBaseLib;
using UnhollowerRuntimeLib; using UnhollowerRuntimeLib;
using Harmony; using Harmony;
using Il2CppSystem.Runtime.InteropServices;
namespace Explorer namespace Explorer
{ {
@ -16,7 +17,7 @@ namespace Explorer
// consts // consts
public const string ID = "com.sinai.cppexplorer"; 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"; public const string AUTHOR = "Sinai";
#if Release_Unity2018 #if Release_Unity2018

View File

@ -146,11 +146,11 @@ MelonLogger.Log(""hello world"");";
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(110) }); GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(110) });
UsingInput = GUILayout.TextField(UsingInput, new GUILayoutOption[] { GUILayout.Width(150) }); UsingInput = GUILayout.TextField(UsingInput, new GUILayoutOption[] { GUILayout.Width(150) });
if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(50) })) if (GUILayout.Button("<b><color=lime>Add</color></b>", new GUILayoutOption[] { GUILayout.Width(120) }))
{ {
AddUsing(UsingInput); AddUsing(UsingInput);
} }
if (GUILayout.Button("<color=red>Reset</color>", null)) if (GUILayout.Button("<b><color=red>Clear All</color></b>", new GUILayoutOption[] { GUILayout.Width(120) }))
{ {
ResetConsole(); ResetConsole();
} }

View File

@ -21,7 +21,6 @@ namespace Explorer
// gameobject list // gameobject list
private Transform m_currentTransform; private Transform m_currentTransform;
private List<GameObjectCache> m_objectList = new List<GameObjectCache>(); private List<GameObjectCache> m_objectList = new List<GameObjectCache>();
private float m_timeOfLastUpdate = -1f;
// search bar // search bar
private bool m_searching = false; private bool m_searching = false;
@ -45,14 +44,6 @@ namespace Explorer
public override void Update() public override void Update()
{ {
if (Time.time - m_timeOfLastUpdate < 0.2f)
{
return;
}
m_timeOfLastUpdate = Time.time;
var start = Time.realtimeSinceStartup;
if (!m_searching) if (!m_searching)
{ {
m_objectList = new List<GameObjectCache>(); m_objectList = new List<GameObjectCache>();
@ -101,7 +92,12 @@ namespace Explorer
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
// Current Scene label // Current Scene label
GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) });
if (SceneManager.sceneCount > 1) try
{
// Need to do 'ToList()' so the object isn't cleaned up by Il2Cpp GC.
var scenes = SceneManager.GetAllScenes().ToList();
if (scenes.Count > 1)
{ {
int changeWanted = 0; int changeWanted = 0;
if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) })) if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) }))
@ -114,20 +110,21 @@ namespace Explorer
} }
if (changeWanted != 0) if (changeWanted != 0)
{ {
var scenes = SceneManager.GetAllScenes();
int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene)); int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene));
index += changeWanted; index += changeWanted;
if (index >= scenes.Count - 1) if (index > scenes.Count - 1)
{ {
index = 0; index = 0;
} }
else if (index > 0) else if (index < 0)
{ {
index = scenes.Count - 1; index = scenes.Count - 1;
} }
m_currentScene = scenes[index].name; m_currentScene = scenes[index].name;
} }
} }
}
catch { }
GUILayout.Label("<color=cyan>" + m_currentScene + "</color>", null); //new GUILayoutOption[] { GUILayout.Width(250) }); GUILayout.Label("<color=cyan>" + m_currentScene + "</color>", null); //new GUILayoutOption[] { GUILayout.Width(250) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
@ -169,17 +166,11 @@ namespace Explorer
if (m_objectList.Count > 0) if (m_objectList.Count > 0)
{ {
var start = Time.realtimeSinceStartup;
foreach (var obj in m_objectList) foreach (var obj in m_objectList)
{ {
//UIStyles.GameobjButton(obj, SetTransformTarget, true, MainMenu.MainRect.width - 170); //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); 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 ------ else // ------ Scene Search results ------