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

Commit ffb6cad

Browse files
committed
1.5.7
* More fixes for failed unstripping, should fix most issues in Audica and other games * If `GetRootSceneObjects` fails and we fall back to the manual implementation, the auto-update for root scene objects will be disabled. Instead, there will be a button to press to update the list. * Transforms are now listed on the Components list in the GameObject inspector * Various cleanups
1 parent d0a4863 commit ffb6cad

File tree

8 files changed

+65
-50
lines changed

8 files changed

+65
-50
lines changed

src/CppExplorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Explorer
1212
public class CppExplorer : MelonMod
1313
{
1414
public const string GUID = "com.sinai.cppexplorer";
15-
public const string VERSION = "1.5.6";
15+
public const string VERSION = "1.5.7";
1616
public const string AUTHOR = "Sinai";
1717

1818
public const string NAME = "CppExplorer"

src/MainMenu/Pages/ConsolePage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Explorer
1414
{
1515
public class ConsolePage : WindowPage
1616
{
17-
public override string Name { get => "C# Console"; set => base.Name = value; }
17+
public override string Name { get => "C# Console"; }
1818

1919
private ScriptEvaluator _evaluator;
2020
private readonly StringBuilder _sb = new StringBuilder();

src/MainMenu/Pages/ScenePage.cs

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ public class ScenePage : WindowPage
1717
public PageHelper Pages = new PageHelper();
1818

1919
private float m_timeOfLastUpdate = -1f;
20-
private static int PASSIVE_UPDATE_INTERVAL = 1;
21-
22-
private static bool m_getRootObjectsFailed = false;
20+
private const int PASSIVE_UPDATE_INTERVAL = 1;
2321

2422
// ----- Holders for GUI elements ----- //
2523

@@ -54,7 +52,7 @@ public void SetTransformTarget(Transform t)
5452
if (m_searching)
5553
CancelSearch();
5654

57-
Update_Impl();
55+
Update_Impl(true);
5856
}
5957

6058
public void TraverseUp()
@@ -90,11 +88,12 @@ public List<GameObjectCache> SearchSceneObjects(string _search)
9088
{
9189
var matches = new List<GameObjectCache>();
9290

93-
foreach (var obj in Resources.FindObjectsOfTypeAll<GameObject>())
91+
foreach (var obj in Resources.FindObjectsOfTypeAll(ReflectionHelpers.GameObjectType))
9492
{
95-
if (obj.name.ToLower().Contains(_search.ToLower()) && obj.scene.name == m_currentScene)
93+
var go = obj.TryCast<GameObject>();
94+
if (go.name.ToLower().Contains(_search.ToLower()) && go.scene.name == m_currentScene)
9695
{
97-
matches.Add(new GameObjectCache(obj));
96+
matches.Add(new GameObjectCache(go));
9897
}
9998
}
10099

@@ -111,9 +110,9 @@ public override void Update()
111110
Update_Impl();
112111
}
113112

114-
private void Update_Impl()
113+
private void Update_Impl(bool manual = false)
115114
{
116-
var allTransforms = new List<Transform>();
115+
List<Transform> allTransforms = new List<Transform>();
117116

118117
// get current list of all transforms (either scene root or our current transform children)
119118
if (m_currentTransform)
@@ -125,30 +124,26 @@ private void Update_Impl()
125124
}
126125
else
127126
{
128-
if (!m_getRootObjectsFailed)
127+
if (!manual && m_getRootObjectsFailed) return;
128+
129+
if (!manual)
129130
{
130131
try
131132
{
132-
var list = SceneManager.GetSceneByName(m_currentScene)
133-
.GetRootGameObjects()
134-
.ToArray();
133+
var scene = SceneManager.GetSceneByName(m_currentScene);
135134

136-
foreach (var obj in list)
137-
{
138-
allTransforms.Add(obj.transform);
139-
}
135+
allTransforms.AddRange(scene.GetRootGameObjects()
136+
.Select(it => it.transform));
140137
}
141138
catch
142139
{
143140
m_getRootObjectsFailed = true;
144-
PASSIVE_UPDATE_INTERVAL = 2;
145-
146-
allTransforms = GetRootObjectsManual_Impl();
141+
allTransforms.AddRange(GetRootObjectsManual_Impl());
147142
}
148143
}
149144
else
150145
{
151-
allTransforms = GetRootObjectsManual_Impl();
146+
allTransforms.AddRange(GetRootObjectsManual_Impl());
152147
}
153148
}
154149

@@ -168,14 +163,30 @@ private void Update_Impl()
168163
}
169164
}
170165

171-
private List<Transform> GetRootObjectsManual_Impl()
166+
private IEnumerable<Transform> GetRootObjectsManual_Impl()
172167
{
173-
var allTransforms = Resources.FindObjectsOfTypeAll<Transform>()
174-
.Where(x => x.parent == null
175-
&& x.gameObject.scene.name == m_currentScene)
176-
.ToList();
168+
try
169+
{
170+
var array = Resources.FindObjectsOfTypeAll(ReflectionHelpers.TransformType);
177171

178-
return allTransforms;
172+
var list = new List<Transform>();
173+
foreach (var obj in array)
174+
{
175+
var transform = obj.TryCast<Transform>();
176+
if (transform.parent == null && transform.gameObject.scene.name == m_currentScene)
177+
{
178+
list.Add(transform);
179+
}
180+
}
181+
return list;
182+
}
183+
catch (Exception e)
184+
{
185+
MelonLogger.Log("Exception getting root scene objects (manual): "
186+
+ e.GetType() + ", " + e.Message + "\r\n"
187+
+ e.StackTrace);
188+
return new Transform[0];
189+
}
179190
}
180191

181192
// --------- GUI Draw Function --------- //
@@ -277,7 +288,7 @@ private void DrawPageButtons()
277288
{
278289
Pages.TurnPage(Turn.Left, ref this.scroll);
279290

280-
Update_Impl();
291+
Update_Impl(true);
281292
}
282293

283294
Pages.CurrentPageLabel();
@@ -286,7 +297,7 @@ private void DrawPageButtons()
286297
{
287298
Pages.TurnPage(Turn.Right, ref this.scroll);
288299

289-
Update_Impl();
300+
Update_Impl(true);
290301
}
291302
}
292303

@@ -316,6 +327,14 @@ private void DrawGameObjectList()
316327
else
317328
{
318329
GUILayout.Label("Scene Root GameObjects:", null);
330+
331+
if (m_getRootObjectsFailed)
332+
{
333+
if (GUILayout.Button("Update Root Object List (auto-update failed!)", null))
334+
{
335+
Update_Impl(true);
336+
}
337+
}
319338
}
320339

321340
if (m_objectList.Count > 0)

src/MainMenu/Pages/SearchPage.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class SearchPage : WindowPage
1313
{
1414
public static SearchPage Instance;
1515

16-
public override string Name { get => "Object Search"; set => base.Name = value; }
16+
public override string Name { get => "Object Search"; }
1717

1818
private string m_searchInput = "";
1919
private string m_typeInput = "";
@@ -318,7 +318,8 @@ private List<object> FindAllObjectsOfType(string _search, string _type)
318318
continue;
319319
}
320320

321-
if (searchType == ReflectionHelpers.ComponentType && ReflectionHelpers.TransformType.IsAssignableFrom(obj.GetIl2CppType()))
321+
if (searchType.FullName == ReflectionHelpers.ComponentType.FullName
322+
&& ReflectionHelpers.TransformType.IsAssignableFrom(obj.GetIl2CppType()))
322323
{
323324
// Transforms shouldn't really be counted as Components, skip them.
324325
// They're more akin to GameObjects.

src/MainMenu/Pages/WindowPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Explorer
99
{
1010
public abstract class WindowPage
1111
{
12-
public virtual string Name { get; set; }
12+
public virtual string Name { get; }
1313

1414
public Vector2 scroll = Vector2.zero;
1515

src/Windows/GameObjectWindow.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,22 @@ public override void Update()
128128
m_object.transform.localScale = m_frozenScale;
129129
}
130130

131-
var list = new List<Transform>();
131+
// update child objects
132+
var childList = new List<Transform>();
132133
for (int i = 0; i < m_object.transform.childCount; i++)
133134
{
134-
list.Add(m_object.transform.GetChild(i));
135+
childList.Add(m_object.transform.GetChild(i));
135136
}
136-
list.Sort((a, b) => b.childCount.CompareTo(a.childCount));
137-
m_children = list.ToArray();
137+
childList.Sort((a, b) => b.childCount.CompareTo(a.childCount));
138+
m_children = childList.ToArray();
138139

139140
ChildPages.ItemCount = m_children.Length;
140141

141-
var list2 = new List<Component>();
142-
foreach (var comp in m_object.GetComponents(ReflectionHelpers.ComponentType))
143-
{
144-
var ilType = comp.GetIl2CppType();
145-
if (ilType == ReflectionHelpers.TransformType)
146-
{
147-
continue;
148-
}
142+
// update components
143+
var compList = new Il2CppSystem.Collections.Generic.List<Component>();
144+
m_object.GetComponentsInternal(ReflectionHelpers.ComponentType, true, false, true, false, compList);
149145

150-
list2.Add(comp);
151-
}
152-
m_components = list2.ToArray();
146+
m_components = compList.ToArray();
153147

154148
CompPages.ItemCount = m_components.Length;
155149
}

src/Windows/TabViewWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public TabViewWindow()
2626
}
2727

2828
public override void Init() { }
29+
2930
public override void Update()
3031
{
3132
while (TargetTabID >= WindowManager.Windows.Count)

src/Windows/WindowManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static UIWindow InspectObject(object obj, out bool createdNew, bool force
109109

110110
if (!equals && iObj is Il2CppSystem.Object iCurrent && window.Target is Il2CppSystem.Object iTarget)
111111
{
112-
if (iCurrent.GetIl2CppType() != iTarget.GetIl2CppType())
112+
if (iCurrent.GetIl2CppType().FullName != iTarget.GetIl2CppType().FullName)
113113
{
114114
if (iCurrent is Transform transform)
115115
{

0 commit comments

Comments
 (0)