Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit b2a90c8

Browse files
committed
1.3.3
Fix scene change buttons not actually working properly.
1 parent 9a784fd commit b2a90c8

File tree

3 files changed

+29
-37
lines changed

3 files changed

+29
-37
lines changed

src/CppExplorer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using UnhollowerBaseLib;
99
using UnhollowerRuntimeLib;
1010
using Harmony;
11+
using Il2CppSystem.Runtime.InteropServices;
1112

1213
namespace Explorer
1314
{
@@ -16,7 +17,7 @@ public class CppExplorer : MelonMod
1617
// consts
1718

1819
public const string ID = "com.sinai.cppexplorer";
19-
public const string VERSION = "1.3.2";
20+
public const string VERSION = "1.3.3";
2021
public const string AUTHOR = "Sinai";
2122

2223
#if Release_Unity2018

src/MainMenu/Pages/ConsolePage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ public override void DrawWindow()
146146
GUILayout.BeginHorizontal(null);
147147
GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(110) });
148148
UsingInput = GUILayout.TextField(UsingInput, new GUILayoutOption[] { GUILayout.Width(150) });
149-
if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(50) }))
149+
if (GUILayout.Button("<b><color=lime>Add</color></b>", new GUILayoutOption[] { GUILayout.Width(120) }))
150150
{
151151
AddUsing(UsingInput);
152152
}
153-
if (GUILayout.Button("<color=red>Reset</color>", null))
153+
if (GUILayout.Button("<b><color=red>Clear All</color></b>", new GUILayoutOption[] { GUILayout.Width(120) }))
154154
{
155155
ResetConsole();
156156
}

src/MainMenu/Pages/ScenePage.cs

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class ScenePage : WindowPage
2121
// gameobject list
2222
private Transform m_currentTransform;
2323
private List<GameObjectCache> m_objectList = new List<GameObjectCache>();
24-
private float m_timeOfLastUpdate = -1f;
2524

2625
// search bar
2726
private bool m_searching = false;
@@ -45,14 +44,6 @@ public void OnSceneChange()
4544

4645
public override void Update()
4746
{
48-
if (Time.time - m_timeOfLastUpdate < 0.2f)
49-
{
50-
return;
51-
}
52-
m_timeOfLastUpdate = Time.time;
53-
54-
var start = Time.realtimeSinceStartup;
55-
5647
if (!m_searching)
5748
{
5849
m_objectList = new List<GameObjectCache>();
@@ -101,33 +92,39 @@ public override void DrawWindow()
10192
GUILayout.BeginHorizontal(null);
10293
// Current Scene label
10394
GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) });
104-
if (SceneManager.sceneCount > 1)
95+
try
10596
{
106-
int changeWanted = 0;
107-
if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) }))
108-
{
109-
changeWanted = -1;
110-
}
111-
if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) }))
112-
{
113-
changeWanted = 1;
114-
}
115-
if (changeWanted != 0)
97+
// Need to do 'ToList()' so the object isn't cleaned up by Il2Cpp GC.
98+
var scenes = SceneManager.GetAllScenes().ToList();
99+
100+
if (scenes.Count > 1)
116101
{
117-
var scenes = SceneManager.GetAllScenes();
118-
int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene));
119-
index += changeWanted;
120-
if (index >= scenes.Count - 1)
102+
int changeWanted = 0;
103+
if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) }))
104+
{
105+
changeWanted = -1;
106+
}
107+
if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) }))
121108
{
122-
index = 0;
109+
changeWanted = 1;
123110
}
124-
else if (index > 0)
111+
if (changeWanted != 0)
125112
{
126-
index = scenes.Count - 1;
113+
int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene));
114+
index += changeWanted;
115+
if (index > scenes.Count - 1)
116+
{
117+
index = 0;
118+
}
119+
else if (index < 0)
120+
{
121+
index = scenes.Count - 1;
122+
}
123+
m_currentScene = scenes[index].name;
127124
}
128-
m_currentScene = scenes[index].name;
129125
}
130126
}
127+
catch { }
131128
GUILayout.Label("<color=cyan>" + m_currentScene + "</color>", null); //new GUILayoutOption[] { GUILayout.Width(250) });
132129

133130
GUILayout.EndHorizontal();
@@ -169,17 +166,11 @@ public override void DrawWindow()
169166

170167
if (m_objectList.Count > 0)
171168
{
172-
var start = Time.realtimeSinceStartup;
173169
foreach (var obj in m_objectList)
174170
{
175171
//UIStyles.GameobjButton(obj, SetTransformTarget, true, MainMenu.MainRect.width - 170);
176172
UIStyles.FastGameobjButton(obj.RefGameObject, obj.EnabledColor, obj.Label, obj.RefGameObject.activeSelf, SetTransformTarget, true, MainMenu.MainRect.width - 170);
177173
}
178-
var diff = Time.realtimeSinceStartup - start;
179-
}
180-
else
181-
{
182-
// if m_currentTransform != null ...
183174
}
184175
}
185176
else // ------ Scene Search results ------

0 commit comments

Comments
 (0)