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

Commit d20461f

Browse files
committed
1.5.5
* Fix for GetRootSceneObjects * Tidy ups
1 parent 72ec340 commit d20461f

File tree

6 files changed

+44
-60
lines changed

6 files changed

+44
-60
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.4";
15+
public const string VERSION = "1.5.5";
1616
public const string AUTHOR = "Sinai";
1717

1818
public const string NAME = "CppExplorer"

src/MainMenu/Pages/ScenePage.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ public override void Update()
7575
else
7676
{
7777
var scene = SceneManager.GetSceneByName(m_currentScene);
78-
var rootObjects = scene.GetRootGameObjects();
7978

80-
foreach (var obj in rootObjects)
79+
var list = new Il2CppSystem.Collections.Generic.List<GameObject>
80+
{
81+
Capacity = scene.rootCount
82+
};
83+
Scene.GetRootGameObjectsInternal(scene.handle, list);
84+
85+
foreach (var obj in list)
8186
{
8287
allTransforms.Add(obj.transform);
8388
}

src/Unstripping/GUIUnstrip.cs

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313

1414
namespace Explorer
1515
{
16-
// This is a manual unstrip of UnityEngine.GUI and UnityEngine.GUILayout methods.
17-
// This code is provided "as-is".
16+
// This is a copy+paste of UnityEngine source code, fixed for Il2Cpp.
1817
// Taken from dnSpy output using Unity 2018.4.20.
1918

20-
// "Unity", Unity logos, and other Unity trademarks are trademarks or
21-
// registered trademarks of Unity Technologies or its affiliates in the
22-
// U.S. and elsewhere.
19+
// Subject to Unity's License and ToS.
2320
// https://unity3d.com/legal/terms-of-service
2421
// https://unity3d.com/legal/terms-of-service/software
2522

@@ -45,7 +42,7 @@ private static GenericStack ScrollStack
4542
// ======= public methods ======= //
4643

4744
// Fix for GUILayoutUtility.GetLastRect().
48-
// Calls UnstripExtensions.GetLastUnstripped.
45+
// Calls UnstripExtensions.GetLastUnstripped().
4946

5047
public static Rect GetLastRect()
5148
{
@@ -62,24 +59,24 @@ public static Rect GetLastRect()
6259
return last;
6360
}
6461

65-
// Fix for GUILayout.Scroller and GUILayout.ScrollerRepeatButton, just calling fixed implementations.
66-
67-
public static float Scroller(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz)
68-
=> Scroller_Impl(position, value, size, leftValue, rightValue, slider, thumb, leftButton, rightButton, horiz);
69-
70-
public static bool ScrollerRepeatButton(int scrollerID, Rect rect, GUIStyle style)
71-
=> ScrollerRepeatButton_Impl(scrollerID, rect, style);
72-
7362
// Simple unstrips for HorizontalScrollbar and VerticalScrollbar, they just call the Scroller unstrip.
7463

7564
public static float HorizontalScrollbar(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle style)
7665
{
77-
return Scroller(position, value, size, leftValue, rightValue, style, GUI.skin.GetStyle(style.name + "thumb"), GUI.skin.GetStyle(style.name + "leftbutton"), GUI.skin.GetStyle(style.name + "rightbutton"), true);
66+
return Scroller_Impl(position, value, size, leftValue, rightValue, style,
67+
GUI.skin.GetStyle(style.name + "thumb"),
68+
GUI.skin.GetStyle(style.name + "leftbutton"),
69+
GUI.skin.GetStyle(style.name + "rightbutton"),
70+
true);
7871
}
7972

8073
public static float VerticalScrollbar(Rect position, float value, float size, float topValue, float bottomValue, GUIStyle style)
8174
{
82-
return Scroller(position, value, size, topValue, bottomValue, style, GUI.skin.GetStyle(style.name + "thumb"), GUI.skin.GetStyle(style.name + "upbutton"), GUI.skin.GetStyle(style.name + "downbutton"), false);
75+
return Scroller_Impl(position, value, size, topValue, bottomValue, style,
76+
GUI.skin.GetStyle(style.name + "thumb"),
77+
GUI.skin.GetStyle(style.name + "upbutton"),
78+
GUI.skin.GetStyle(style.name + "downbutton"),
79+
false);
8380
}
8481

8582
// Fix for BeginScrollView.
@@ -106,7 +103,7 @@ public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] o
106103
{
107104
try
108105
{
109-
return BeginScrollView_Impl(scroll, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.scrollView, options);
106+
return BeginScrollView_ImplLayout(scroll, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.scrollView, options);
110107
}
111108
catch (Exception e)
112109
{
@@ -141,16 +138,13 @@ public static void EndScrollView(bool handleScrollWheel = true)
141138

142139
// Actual unstrip of GUILayout.BeginScrollView()
143140

144-
private static Vector2 BeginScrollView_Impl(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar,
145-
GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options)
141+
private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical,
142+
GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options)
146143
{
147144
GUIUtility.CheckOnGUI();
148145

149-
var guiscrollGroup = (GUIScrollGroup)GUILayoutUtility.BeginLayoutGroup(
150-
background,
151-
null,
152-
Il2CppType.Of<GUIScrollGroup>()
153-
).Il2CppCast(typeof(GUIScrollGroup));
146+
var guiscrollGroup = GUILayoutUtility.BeginLayoutGroup(background, null, Il2CppType.Of<GUIScrollGroup>())
147+
.TryCast<GUIScrollGroup>();
154148

155149
EventType type = Event.current.type;
156150
if (type == EventType.Layout)
@@ -177,16 +171,16 @@ private static Vector2 BeginScrollView_Impl(Vector2 scrollPosition, bool alwaysS
177171
);
178172
}
179173

180-
// Actual unstrip of GUI.BeginScrollView() -- note: not GUILayout.
174+
// Actual unstrip of GUI.BeginScrollView()
181175

182-
private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal, bool alwaysShowVertical,
183-
GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background)
176+
private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal,
177+
bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background)
184178
{
185179
GUIUtility.CheckOnGUI();
186180

187181
int controlID = GUIUtility.GetControlID(GUI.s_ScrollviewHash, FocusType.Passive);
188182

189-
var scrollViewState = (ScrollViewState)GUIUtility.GetStateObject(Il2CppType.Of<ScrollViewState>(), controlID).Il2CppCast(typeof(ScrollViewState));
183+
var scrollViewState = GUIUtility.GetStateObject(Il2CppType.Of<ScrollViewState>(), controlID).TryCast<ScrollViewState>();
190184

191185
var scrollExt = ScrollViewStateUnstrip.FromPointer(scrollViewState.Pointer);
192186

@@ -310,16 +304,13 @@ private static void EndScrollView_Impl(bool handleScrollWheel)
310304

311305
if (ScrollStack.Count <= 0) return;
312306

313-
//ScrollViewState scrollViewState = (ScrollViewState)GUI.s_ScrollViewStates.Peek();
314-
var state = (ScrollViewState)ScrollStack.Peek().Il2CppCast(typeof(ScrollViewState));
315-
//ScrollViewExtensions.Dict.TryGetValue(state.Pointer, out ScrollViewExtensions scrollExt);
307+
var state = ScrollStack.Peek().TryCast<ScrollViewState>();
316308
var scrollExt = ScrollViewStateUnstrip.FromPointer(state.Pointer);
317309

318310
if (scrollExt == null) throw new Exception("Could not get scrollExt!");
319311

320312
GUIClip.Pop();
321313

322-
//GUI.s_ScrollViewStates.Pop();
323314
ScrollStack.Pop();
324315

325316
var position = scrollExt.position;
@@ -339,7 +330,6 @@ private static void EndScrollView_Impl(bool handleScrollWheel)
339330
pos.y = 0f;
340331
}
341332

342-
// state.apply = true;
343333
scrollExt.apply = true;
344334

345335
Event.current.Use();
@@ -368,7 +358,6 @@ private static float Scroller_Impl(Rect position, float value, float size, float
368358
rect2 = new Rect(position.x, position.yMax - rightButton.fixedHeight, position.width, rightButton.fixedHeight);
369359
}
370360

371-
//value = GUI.Slider(position2, value, size, leftValue, rightValue, slider, thumb, horiz, controlID);
372361
value = Slider(position2, value, size, leftValue, rightValue, slider, thumb, horiz, controlID);
373362

374363
bool flag = Event.current.type == EventType.MouseUp;
@@ -382,8 +371,7 @@ private static float Scroller_Impl(Rect position, float value, float size, float
382371
}
383372
if (flag && Event.current.type == EventType.Used)
384373
{
385-
//GUI.s_ScrollControlId = 0;
386-
GUIUnstrip.s_ScrollControlId = 0;
374+
s_ScrollControlId = 0;
387375
}
388376
if (leftValue < rightValue)
389377
{
@@ -400,7 +388,6 @@ private static float Scroller_Impl(Rect position, float value, float size, float
400388

401389
public static float Slider(Rect position, float value, float size, float start, float end, GUIStyle slider, GUIStyle thumb, bool horiz, int id)
402390
{
403-
//GUIUtility.CheckOnGUI();
404391
if (id == 0)
405392
{
406393
id = GUIUtility.GetControlID(GUI.s_SliderHash, FocusType.Passive, position);
@@ -416,11 +403,8 @@ private static bool ScrollerRepeatButton_Impl(int scrollerID, Rect rect, GUIStyl
416403
bool result = false;
417404
if (GUI.DoRepeatButton(rect, GUIContent.none, style, FocusType.Passive))
418405
{
419-
//bool flag = GUI.s_ScrollControlId != scrollerID;
420-
//GUI.s_ScrollControlId = scrollerID;
421-
422-
bool flag = GUIUnstrip.s_ScrollControlId != scrollerID;
423-
GUIUnstrip.s_ScrollControlId = scrollerID;
406+
bool flag = s_ScrollControlId != scrollerID;
407+
s_ScrollControlId = scrollerID;
424408

425409
if (flag)
426410
{

src/Unstripping/ScrollViewStateUnstrip.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
using UnityEngine;
99

1010
namespace Explorer
11-
{
12-
// This is a manual unstrip of UnityEngine.ScrollViewState.
13-
// This code is provided "as-is".
11+
{
12+
// This is a copy+paste of UnityEngine source code, fixed for Il2Cpp.
1413
// Taken from dnSpy output using Unity 2018.4.20.
1514

16-
// "Unity", Unity logos, and other Unity trademarks are trademarks or
17-
// registered trademarks of Unity Technologies or its affiliates in the
18-
// U.S. and elsewhere.
15+
// Subject to Unity's License and ToS.
1916
// https://unity3d.com/legal/terms-of-service
2017
// https://unity3d.com/legal/terms-of-service/software
2118

src/Unstripping/SliderHandlerUnstrip.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
namespace Explorer
1010
{
11-
// This is a manual unstrip of UnityEngine.SliderHandler.
12-
// This code is provided "as-is".
11+
// This is a copy+paste of UnityEngine source code, fixed for Il2Cpp.
1312
// Taken from dnSpy output using Unity 2018.4.20.
1413

15-
// "Unity", Unity logos, and other Unity trademarks are trademarks or
16-
// registered trademarks of Unity Technologies or its affiliates in the
17-
// U.S. and elsewhere.
14+
// Subject to Unity's License and ToS.
1815
// https://unity3d.com/legal/terms-of-service
1916
// https://unity3d.com/legal/terms-of-service/software
2017

@@ -282,7 +279,7 @@ private void StartDraggingWithValue(float dragStartValue)
282279

283280
private SliderState SliderState()
284281
{
285-
return (SliderState)GUIUtility.GetStateObject(Il2CppType.Of<SliderState>(), this.id).Il2CppCast(typeof(SliderState));
282+
return (SliderState)GUIUtility.GetStateObject(Il2CppType.Of<SliderState>(), this.id).TryCast<SliderState>();
286283
}
287284

288285
private Rect ThumbRect()

src/Unstripping/UnstripExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
namespace Explorer
99
{
10-
// "Unity", Unity logos, and other Unity trademarks are trademarks or
11-
// registered trademarks of Unity Technologies or its affiliates in the
12-
// U.S. and elsewhere.
10+
// This is a copy+paste of UnityEngine source code, fixed for Il2Cpp.
11+
// Taken from dnSpy output using Unity 2018.4.20.
12+
13+
// Subject to Unity's License and ToS.
1314
// https://unity3d.com/legal/terms-of-service
1415
// https://unity3d.com/legal/terms-of-service/software
1516

0 commit comments

Comments
 (0)