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

Commit 9efb958

Browse files
committed
Cleanups, method summaries, bump version
1 parent f10a462 commit 9efb958

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

src/ExplorerCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace UnityExplorer
1515
public class ExplorerCore
1616
{
1717
public const string NAME = "UnityExplorer";
18-
public const string VERSION = "3.2.1";
18+
public const string VERSION = "3.2.2";
1919
public const string AUTHOR = "Sinai";
2020
public const string GUID = "com.sinai.unityexplorer";
2121

src/Helpers/ICallHelper.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@ public static class ICallHelper
1111
{
1212
private static readonly Dictionary<string, Delegate> iCallCache = new Dictionary<string, Delegate>();
1313

14-
public static T GetICall<T>(string iCallName) where T : Delegate
14+
/// <summary>
15+
/// Helper to get and cache an iCall by providing the signature (eg. "UnityEngine.Resources::FindObjectsOfTypeAll").
16+
/// </summary>
17+
/// <typeparam name="T">The Type of Delegate to provide for the iCall.</typeparam>
18+
/// <param name="signature">The signature of the iCall you want to get.</param>
19+
/// <returns>The <typeparamref name="T"/> delegate if successful.</returns>
20+
/// <exception cref="MissingMethodException">If the iCall could not be found.</exception>
21+
public static T GetICall<T>(string signature) where T : Delegate
1522
{
16-
if (iCallCache.ContainsKey(iCallName))
17-
return (T)iCallCache[iCallName];
23+
if (iCallCache.ContainsKey(signature))
24+
return (T)iCallCache[signature];
1825

19-
IntPtr ptr = il2cpp_resolve_icall(iCallName);
26+
IntPtr ptr = il2cpp_resolve_icall(signature);
2027

2128
if (ptr == IntPtr.Zero)
2229
{
23-
throw new MissingMethodException($"Could not resolve internal call by name '{iCallName}'!");
30+
throw new MissingMethodException($"Could not resolve internal call by name '{signature}'!");
2431
}
2532

2633
Delegate iCall = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
27-
iCallCache.Add(iCallName, iCall);
34+
iCallCache.Add(signature, iCall);
2835

2936
return (T)iCall;
3037
}

src/Inspectors/Reflection/CacheObject/CacheMember.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ internal void AddArgRow(int i, GameObject parent)
381381
argLabelLayout.minHeight = 25;
382382
var argText = argLabelObj.GetComponent<Text>();
383383
var argTypeTxt = UISyntaxHighlight.ParseFullSyntax(arg.ParameterType, false);
384-
argText.text = $"{argTypeTxt} <color={UISyntaxHighlight.Local}>{arg.Name}</color>";
384+
argText.text = $"{argTypeTxt} <color={UISyntaxHighlight.LOCAL_ARG}>{arg.Name}</color>";
385385

386386
var argInputObj = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
387387
var argInputLayout = argInputObj.AddComponent<LayoutElement>();

src/Inspectors/Reflection/CacheObject/CacheMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ internal void AddGenericArgRow(int i, GameObject parent)
168168
//var argLayout = argLabelObj.AddComponent<LayoutElement>();
169169
//argLayout.minWidth = 20;
170170
var argText = argLabelObj.GetComponent<Text>();
171-
argText.text = $"{constrainTxt} <color={UISyntaxHighlight.Enum}>{arg.Name}</color>";
171+
argText.text = $"{constrainTxt} <color={UISyntaxHighlight.CONST_VAR}>{arg.Name}</color>";
172172

173173
var argInputObj = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
174174
var argInputLayout = argInputObj.AddComponent<LayoutElement>();

src/UI/UISyntaxHighlight.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ namespace UnityExplorer.UI
88
{
99
public class UISyntaxHighlight
1010
{
11-
public const string Field_Static = "#8d8dc6";
12-
public const string Field_Instance = "#c266ff";
11+
public const string FIELD_STATIC = "#8d8dc6";
12+
public const string FIELD_INSTANCE = "#c266ff";
1313

14-
public const string Method_Static = "#b55b02";
15-
public const string Method_Instance = "#ff8000";
14+
public const string METHOD_STATIC = "#b55b02";
15+
public const string METHOD_INSTANCE = "#ff8000";
1616

17-
public const string Prop_Static = "#588075";
18-
public const string Prop_Instance = "#55a38e";
17+
public const string PROP_STATIC = "#588075";
18+
public const string PROP_INSTANCE = "#55a38e";
1919

20-
public const string Class_Static = "#3a8d71";
21-
public const string Class_Instance = "#2df7b2";
20+
public const string CLASS_STATIC = "#3a8d71";
21+
public const string CLASS_INSTANCE = "#2df7b2";
2222

23-
public const string Local = "#a6e9e9";
23+
public const string CLASS_STRUCT = "#0fba3a";
2424

25-
public const string StructGreen = "#0fba3a";
25+
public const string LOCAL_ARG = "#a6e9e9";
2626

27-
public static string Enum = "#92c470";
27+
public static string CONST_VAR = "#92c470";
2828

2929
internal static readonly Color s_silver = new Color(0.66f, 0.66f, 0.66f);
3030

3131
internal static string GetClassColor(Type type)
3232
{
3333
if (type.IsAbstract && type.IsSealed)
34-
return Class_Static;
34+
return CLASS_STATIC;
3535
else if (type.IsEnum || type.IsGenericParameter)
36-
return Enum;
36+
return CONST_VAR;
3737
else if (type.IsValueType)
38-
return StructGreen;
38+
return CLASS_STRUCT;
3939
else
40-
return Class_Instance;
40+
return CLASS_INSTANCE;
4141
}
4242

4343
public static string ParseFullSyntax(Type type, bool includeNamespace, MemberInfo memberInfo = null)
@@ -49,7 +49,7 @@ public static string ParseFullSyntax(Type type, bool includeNamespace, MemberInf
4949

5050
if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter))
5151
{
52-
ret = $"<color={Enum}>{type.Name}</color>";
52+
ret = $"<color={CONST_VAR}>{type.Name}</color>";
5353
}
5454
else
5555
{
@@ -134,7 +134,7 @@ private static string ParseGenericArgs(Type[] gArgs, bool allGeneric = false)
134134

135135
if (allGeneric)
136136
{
137-
args += $"<color={Enum}>{arg.Name}</color>";
137+
args += $"<color={CONST_VAR}>{arg.Name}</color>";
138138
continue;
139139
}
140140

@@ -153,30 +153,30 @@ private static string GetMemberInfoColor(MemberInfo memberInfo, out bool isStati
153153
if (fi.IsStatic)
154154
{
155155
isStatic = true;
156-
memberColor = Field_Static;
156+
memberColor = FIELD_STATIC;
157157
}
158158
else
159-
memberColor = Field_Instance;
159+
memberColor = FIELD_INSTANCE;
160160
}
161161
else if (memberInfo is MethodInfo mi)
162162
{
163163
if (mi.IsStatic)
164164
{
165165
isStatic = true;
166-
memberColor = Method_Static;
166+
memberColor = METHOD_STATIC;
167167
}
168168
else
169-
memberColor = Method_Instance;
169+
memberColor = METHOD_INSTANCE;
170170
}
171171
else if (memberInfo is PropertyInfo pi)
172172
{
173173
if (pi.GetAccessors(true)[0].IsStatic)
174174
{
175175
isStatic = true;
176-
memberColor = Prop_Static;
176+
memberColor = PROP_STATIC;
177177
}
178178
else
179-
memberColor = Prop_Instance;
179+
memberColor = PROP_INSTANCE;
180180
}
181181
return memberColor;
182182
}

0 commit comments

Comments
 (0)