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

Commit 867370c

Browse files
committed
2.0.1
* Added unstrip fix for GetRootSceneObjects using Il2CPP internal call
1 parent 35eb78c commit 867370c

15 files changed

+532
-446
lines changed

src/CacheObject/CacheField.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public override void SetValue()
3838
{
3939
var fi = MemInfo as FieldInfo;
4040
fi.SetValue(fi.IsStatic ? null : DeclaringInstance, IValue.Value);
41-
42-
base.SetValue();
4341
}
4442
}
4543
}

src/CacheObject/CacheMember.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ public void DrawArgsInput()
126126
GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]);
127127

128128
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
129+
129130
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
130-
this.m_argumentInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
131+
GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) });
132+
this.m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
133+
131134
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
132-
GUILayout.Label(label, new GUILayoutOption[0]);
133135

134136
GUILayout.EndHorizontal();
135137
}

src/CacheObject/CacheProperty.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public override void SetValue()
5353
var target = pi.GetAccessors()[0].IsStatic ? null : DeclaringInstance;
5454

5555
pi.SetValue(target, IValue.Value, ParseArguments());
56-
57-
base.SetValue();
5856
}
5957
}
6058
}

src/Explorer.csproj

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<DefineConstants>CPP,ML</DefineConstants>
4242
<IsCpp>true</IsCpp>
4343
<IsMelonLoader>true</IsMelonLoader>
44+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4445
</PropertyGroup>
4546
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_ML_Mono|AnyCPU' ">
4647
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
@@ -49,20 +50,23 @@
4950
<Prefer32Bit>false</Prefer32Bit>
5051
<IsCpp>false</IsCpp>
5152
<IsMelonLoader>true</IsMelonLoader>
53+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5254
</PropertyGroup>
5355
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_BIE_Cpp|AnyCPU' ">
5456
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
5557
<OutputPath>..\Release\Explorer.BepInEx.Il2Cpp\</OutputPath>
5658
<DefineConstants>CPP,BIE</DefineConstants>
5759
<IsCpp>true</IsCpp>
5860
<IsMelonLoader>false</IsMelonLoader>
61+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5962
</PropertyGroup>
6063
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_BIE_Mono|AnyCPU' ">
6164
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
6265
<OutputPath>..\Release\Explorer.BepInEx.Mono\</OutputPath>
6366
<DefineConstants>MONO,BIE</DefineConstants>
6467
<IsCpp>false</IsCpp>
6568
<IsMelonLoader>false</IsMelonLoader>
69+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6670
</PropertyGroup>
6771
<ItemGroup>
6872
<Reference Include="System" />
@@ -230,7 +234,6 @@
230234
<Compile Include="Input\InputSystem.cs" />
231235
<Compile Include="Input\LegacyInput.cs" />
232236
<Compile Include="Input\NoInput.cs" />
233-
<Compile Include="Tests\TestClass.cs" />
234237
<Compile Include="UI\Inspectors\InspectUnderMouse.cs" />
235238
<Compile Include="UI\Inspectors\Reflection\InstanceInspector.cs" />
236239
<Compile Include="UI\Inspectors\ReflectionInspector.cs" />
@@ -254,13 +257,14 @@
254257
<Compile Include="UI\TabViewWindow.cs" />
255258
<Compile Include="UI\WindowBase.cs" />
256259
<Compile Include="UI\WindowManager.cs" />
257-
<Compile Include="UnstripFixes\GUIUnstrip.cs" />
258-
<Compile Include="UnstripFixes\Internal_LayoutUtility.cs" />
259-
<Compile Include="UnstripFixes\Internal_ScrollViewState.cs" />
260-
<Compile Include="UnstripFixes\Internal_SliderHandler.cs" />
260+
<Compile Include="Unstrip\Scene\SceneUnstrip.cs" />
261+
<Compile Include="Unstrip\IMGUI\GUIUnstrip.cs" />
262+
<Compile Include="Unstrip\IMGUI\Internal_LayoutUtility.cs" />
263+
<Compile Include="Unstrip\IMGUI\Internal_ScrollViewState.cs" />
264+
<Compile Include="Unstrip\IMGUI\Internal_SliderHandler.cs" />
261265
<Compile Include="Properties\AssemblyInfo.cs" />
262-
<Compile Include="UnstripFixes\Internal.cs" />
263-
<Compile Include="UnstripFixes\Internal_SliderState.cs" />
266+
<Compile Include="Unstrip\IMGUI\Internal.cs" />
267+
<Compile Include="Unstrip\IMGUI\Internal_SliderState.cs" />
264268
</ItemGroup>
265269
<ItemGroup>
266270
<None Include="ILRepack.targets" />

src/ExplorerCore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Explorer
1010
public class ExplorerCore
1111
{
1212
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
13-
public const string VERSION = "2.0.0";
13+
public const string VERSION = "2.0.1";
1414
public const string AUTHOR = "Sinai";
1515
public const string GUID = "com.sinai.explorer";
1616

@@ -68,7 +68,7 @@ public static void Update()
6868

6969
if (ShowMenu)
7070
{
71-
//CursorControl.Update();
71+
ForceUnlockCursor.Update();
7272
InspectUnderMouse.Update();
7373

7474
MainMenu.Instance.Update();

src/Input/InputManager.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Reflection;
33
using UnityEngine;
44
using Explorer.Input;
5+
#if CPP
6+
using UnhollowerBaseLib;
7+
#endif
58

69
namespace Explorer
710
{
@@ -15,7 +18,7 @@ public static void Init()
1518
{
1619
inputModule = new InputSystem();
1720
}
18-
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.Input", LegacyInput.TInput))
21+
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.InputLegacyModule", LegacyInput.TInput))
1922
{
2023
inputModule = new LegacyInput();
2124
}
@@ -38,5 +41,34 @@ public static void Init()
3841

3942
public static bool GetMouseButtonDown(int btn) => inputModule.GetMouseButtonDown(btn);
4043
public static bool GetMouseButton(int btn) => inputModule.GetMouseButton(btn);
44+
45+
//#if CPP
46+
//#pragma warning disable IDE1006
47+
// // public extern static string compositionString { get; }
48+
49+
// internal delegate string get_compositionString_delegate();
50+
// internal static get_compositionString_delegate get_compositionString_iCall =
51+
// IL2CPP.ResolveICall<get_compositionString_delegate>("UnityEngine.Input::get_compositionString");
52+
53+
// public static string compositionString => get_compositionString_iCall();
54+
55+
// // public extern static Vector2 compositionCursorPos { get; set; }
56+
57+
// internal delegate Vector2 get_compositionCursorPos_delegate();
58+
// internal static get_compositionCursorPos_delegate get_compositionCursorPos_iCall =
59+
// IL2CPP.ResolveICall<get_compositionCursorPos_delegate>("UnityEngine.Input::get_compositionCursorPos");
60+
61+
// internal delegate void set_compositionCursorPos_delegate(Vector2 value);
62+
// internal static set_compositionCursorPos_delegate set_compositionCursorPos_iCall =
63+
// IL2CPP.ResolveICall<set_compositionCursorPos_delegate>("UnityEngine.Input::set_compositionCursorPos");
64+
65+
// public static Vector2 compositionCursorPos
66+
// {
67+
// get => get_compositionCursorPos_iCall();
68+
// set => set_compositionCursorPos_iCall(value);
69+
// }
70+
71+
//#pragma warning restore IDE1006
72+
//#endif
4173
}
42-
}
74+
}

src/Tests/TestClass.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
using System;
44
using UnityEngine;
55
using System.Reflection;
6+
using System.Runtime.InteropServices;
7+
#if CPP
8+
using UnhollowerBaseLib;
9+
using UnityEngine.SceneManagement;
10+
#endif
611

712
namespace Explorer.Tests
813
{
@@ -32,6 +37,14 @@ public class TestClass
3237
public static int StaticField = 5;
3338
public int NonStaticField;
3439

40+
#if CPP
41+
public static IntPtr FindICall(string name) => il2cpp_resolve_icall(name);
42+
43+
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
44+
private static extern IntPtr il2cpp_resolve_icall([MarshalAs(UnmanagedType.LPStr)] string name);
45+
46+
#endif
47+
3548
#if CPP
3649
public static Il2CppSystem.Collections.Generic.HashSet<string> ILHashSetTest;
3750
#endif

src/UnstripFixes/GUIUnstrip.cs renamed to src/Unstrip/IMGUI/GUIUnstrip.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
using System.Reflection;
44
using UnityEngine;
55
#if CPP
6-
using Explorer.UnstripInternals;
6+
using Explorer.Unstrip.IMGUI;
77
#endif
88

99
namespace Explorer
1010
{
1111
public class GUIUnstrip
1212
{
13-
public static void BeginHorizontal(params GUILayoutOption[] options)
13+
public static void BeginHorizontal(params GUILayoutOption[] options)
1414
=> BeginHorizontal(GUIContent.none, GUIStyle.none, options);
1515

16-
public static void BeginHorizontal(GUIStyle style, params GUILayoutOption[] options)
16+
public static void BeginHorizontal(GUIStyle style, params GUILayoutOption[] options)
1717
=> BeginHorizontal(GUIContent.none, style, options);
1818

1919
public static void BeginHorizontal(GUIContent content, GUIStyle style, params GUILayoutOption[] options)
@@ -25,11 +25,11 @@ public static void BeginHorizontal(GUIContent content, GUIStyle style, params GU
2525
#endif
2626
}
2727

28-
public static void BeginVertical(params GUILayoutOption[] options)
28+
public static void BeginVertical(params GUILayoutOption[] options)
2929
=> BeginVertical(GUIContent.none, GUIStyle.none, options);
3030

3131
public static void BeginVertical(GUIStyle style, params GUILayoutOption[] options)
32-
=> BeginVertical(GUIContent.none, style, options);
32+
=> BeginVertical(GUIContent.none, style, options);
3333

3434
public static void BeginVertical(GUIContent content, GUIStyle style, params GUILayoutOption[] options)
3535
{

src/UnstripFixes/Internal.cs renamed to src/Unstrip/IMGUI/Internal.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
using UnityEngineInternal;
77
using UnhollowerRuntimeLib;
88

9-
namespace Explorer.UnstripInternals
9+
namespace Explorer.Unstrip.IMGUI
1010
{
1111
public class Internal
1212
{
1313
#region Properties
1414
public static int s_ScrollControlId;
1515

1616
public static bool ScrollFailed = false;
17-
public static bool ManualUnstripFailed = false;
17+
public static bool ManualUnstripFailed = false;
1818

1919
public static GenericStack ScrollStack => m_scrollStack ?? GetScrollStack();
2020
public static PropertyInfo m_scrollViewStatesInfo;
@@ -73,7 +73,7 @@ private static GenericStack GetScrollStack()
7373

7474
if (m_stateCacheDict == null) throw new Exception();
7575
}
76-
catch
76+
catch
7777
{
7878
m_stateCacheDict = new Dictionary<int, Il2CppSystem.Object>();
7979
}
@@ -117,7 +117,7 @@ public static void BeginLayoutDirection(bool vertical, GUIContent content, GUISt
117117

118118
public static string TextField(string text, GUILayoutOption[] options)
119119
{
120-
text = text ?? "";
120+
text = text ?? string.Empty;
121121

122122
int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
123123
GUIContent guicontent = GUIContent.Temp(text);
@@ -275,7 +275,7 @@ public static void EndArea()
275275
GUI.EndGroup();
276276
}
277277

278-
#endregion
278+
#endregion
279279

280280
#region Scrolling
281281

@@ -422,7 +422,7 @@ private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPositio
422422
var scrollViewState = GetStateObject(Il2CppType.Of<ScrollViewState>(), controlID)
423423
.TryCast<ScrollViewState>();
424424

425-
if (scrollViewState == null)
425+
if (scrollViewState == null)
426426
return scrollPosition;
427427

428428
var scrollExt = Internal_ScrollViewState.FromPointer(scrollViewState.Pointer);
@@ -660,7 +660,7 @@ private static bool ScrollerRepeatButton(int scrollerID, Rect rect, GUIStyle sty
660660
return result;
661661
}
662662

663-
#endregion
663+
#endregion
664664
}
665665

666666
#region Extensions

src/UnstripFixes/Internal_LayoutUtility.cs renamed to src/Unstrip/IMGUI/Internal_LayoutUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#if CPP
22
using UnityEngine;
33

4-
namespace Explorer.UnstripInternals
4+
namespace Explorer.Unstrip.IMGUI
55
{
66
public class Internal_LayoutUtility
77
{
@@ -85,7 +85,7 @@ public static Rect GetLastRect()
8585
last = GUILayoutUtility.kDummyRect;
8686
}
8787
return last;
88-
}
88+
}
8989
}
9090
}
9191
#endif

0 commit comments

Comments
 (0)