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

Commit 91d5fc2

Browse files
committed
almost done, just interactive unity structs and a few minor things to finish off.
1 parent 4a1125c commit 91d5fc2

26 files changed

+1006
-218
lines changed

lib/UnityEngine.UI.dll

243 KB
Binary file not shown.

lib/UnityEngine.dll

1.37 MB
Binary file not shown.

src/CSConsole/CSharpLexer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CSharpLexer
3434

3535
public static char indentOpen = '{';
3636
public static char indentClose = '}';
37-
private static readonly StringBuilder indentBuilder = new StringBuilder();
37+
private static StringBuilder indentBuilder = new StringBuilder();
3838

3939
public static char[] delimiters = new[]
4040
{
@@ -153,7 +153,7 @@ public IEnumerable<LexerMatchInfo> GetMatches(string input)
153153

154154
public static string GetIndentForInput(string input, int indent, out int caretPosition)
155155
{
156-
indentBuilder.Clear();
156+
indentBuilder = new StringBuilder();
157157

158158
indent += 1;
159159

src/ExplorerBepInPlugin.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ public override void Load()
6161

6262
var obj = new GameObject(
6363
"ExplorerBehaviour",
64-
new Il2CppSystem.Type[]
65-
{
66-
Il2CppType.Of<ExplorerBehaviour>()
67-
}
64+
new Il2CppSystem.Type[] { Il2CppType.Of<ExplorerBehaviour>() }
6865
);
66+
obj.hideFlags = HideFlags.HideAndDontSave;
6967
GameObject.DontDestroyOnLoad(obj);
7068

7169
new ExplorerCore();

src/Helpers/ReflectionHelpers.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ public static Type GetActualType(object obj)
7777
// check if type is injected
7878
IntPtr classPtr = il2cpp_object_get_class(ilObject.Pointer);
7979
if (RuntimeSpecificsStore.IsInjected(classPtr))
80-
return GetTypeByName(il2cppType.FullName);
80+
{
81+
var typeByName = GetTypeByName(il2cppType.FullName);
82+
if (typeByName != null)
83+
return typeByName;
84+
}
8185

8286
// this should be fine for all other il2cpp objects
8387
var getType = GetMonoType(il2cppType);
@@ -252,7 +256,13 @@ public static bool IsDictionary(Type t)
252256
public static string ExceptionToString(Exception e, bool innerMost = false)
253257
{
254258
while (innerMost && e.InnerException != null)
259+
{
260+
#if CPP
261+
if (e.InnerException is System.Runtime.CompilerServices.RuntimeWrappedException runtimeEx)
262+
break;
263+
#endif
255264
e = e.InnerException;
265+
}
256266

257267
return e.GetType() + ", " + e.Message;
258268
}

src/Inspectors/Reflection/CacheObject/CacheEnumerated.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace UnityExplorer.Inspectors.Reflection
1212
public class CacheEnumerated : CacheObjectBase
1313
{
1414
public override Type FallbackType => ParentEnumeration.m_baseEntryType;
15-
public override bool CanWrite => RefIList != null && ParentEnumeration.OwnerCacheObject.CanWrite;
15+
public override bool CanWrite => RefIList != null && ParentEnumeration.Owner.CanWrite;
1616

1717
public int Index { get; set; }
1818
public IList RefIList { get; set; }
@@ -29,15 +29,15 @@ public CacheEnumerated(int index, InteractiveEnumerable parentEnumeration, IList
2929
public override void CreateIValue(object value, Type fallbackType)
3030
{
3131
IValue = InteractiveValue.Create(value, fallbackType);
32-
IValue.OwnerCacheObject = this;
32+
IValue.Owner = this;
3333
}
3434

3535
public override void SetValue()
3636
{
3737
RefIList[Index] = IValue.Value;
3838
ParentEnumeration.Value = RefIList;
3939

40-
ParentEnumeration.OwnerCacheObject.SetValue();
40+
ParentEnumeration.Owner.SetValue();
4141
}
4242

4343
internal override void ConstructUI()

src/Inspectors/Reflection/CacheObject/CacheMember.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public CacheMember(MemberInfo memberInfo, object declaringInstance)
4848
MemInfo = memberInfo;
4949
DeclaringType = memberInfo.DeclaringType;
5050
DeclaringInstance = declaringInstance;
51+
#if CPP
52+
if (DeclaringInstance != null)
53+
DeclaringInstance = DeclaringInstance.Il2CppCast(DeclaringType);
54+
#endif
5155
}
5256

5357
public static bool CanProcessArgs(ParameterInfo[] parameters)
@@ -70,7 +74,7 @@ public static bool CanProcessArgs(ParameterInfo[] parameters)
7074
public override void CreateIValue(object value, Type fallbackType)
7175
{
7276
IValue = InteractiveValue.Create(value, fallbackType);
73-
IValue.OwnerCacheObject = this;
77+
IValue.Owner = this;
7478
IValue.m_mainContentParent = this.m_rightGroup;
7579
IValue.m_subContentParent = this.m_subContent;
7680
}
@@ -384,7 +388,7 @@ internal void AddArgRow(int i, GameObject parent)
384388
argInputLayout.minWidth = 20;
385389
argInputLayout.minHeight = 25;
386390
argInputLayout.flexibleHeight = 0;
387-
argInputLayout.layoutPriority = 2;
391+
//argInputLayout.layoutPriority = 2;
388392

389393
var argInput = argInputObj.GetComponent<InputField>();
390394
argInput.onValueChanged.AddListener((string val) => { m_argumentInput[i] = val; });

src/Inspectors/Reflection/CacheObject/CacheObjectBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public virtual void Enable()
3737

3838
public virtual void Disable()
3939
{
40-
m_mainContent?.SetActive(false);
40+
if (m_mainContent)
41+
m_mainContent.SetActive(false);
4142
}
4243

4344
public void Destroy()

src/Inspectors/Reflection/CacheObject/CachePaired.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public CachePaired(int index, InteractiveDictionary parentDict, IDictionary refI
4141
public override void CreateIValue(object value, Type fallbackType)
4242
{
4343
IValue = InteractiveValue.Create(value, fallbackType);
44-
IValue.OwnerCacheObject = this;
44+
IValue.Owner = this;
4545
}
4646

4747
#region UI CONSTRUCTION

src/Inspectors/Reflection/CacheObject/CacheProperty.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ public override void UpdateReflection()
4343
}
4444
else
4545
{
46-
// todo write-only properties?
46+
if (FallbackType == typeof(string))
47+
{
48+
IValue.Value = "";
49+
}
50+
else if (FallbackType.IsPrimitive)
51+
{
52+
IValue.Value = Activator.CreateInstance(FallbackType);
53+
}
54+
m_evaluated = true;
55+
ReflectionException = null;
4756
}
4857
}
4958

0 commit comments

Comments
 (0)