mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-06 01:23:31 +08:00
Cleanups, method summaries, bump version
This commit is contained in:
parent
f10a462b00
commit
9efb9581f5
@ -15,7 +15,7 @@ namespace UnityExplorer
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "UnityExplorer";
|
||||
public const string VERSION = "3.2.1";
|
||||
public const string VERSION = "3.2.2";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
|
||||
|
@ -11,20 +11,27 @@ namespace UnityExplorer.Helpers
|
||||
{
|
||||
private static readonly Dictionary<string, Delegate> iCallCache = new Dictionary<string, Delegate>();
|
||||
|
||||
public static T GetICall<T>(string iCallName) where T : Delegate
|
||||
/// <summary>
|
||||
/// Helper to get and cache an iCall by providing the signature (eg. "UnityEngine.Resources::FindObjectsOfTypeAll").
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The Type of Delegate to provide for the iCall.</typeparam>
|
||||
/// <param name="signature">The signature of the iCall you want to get.</param>
|
||||
/// <returns>The <typeparamref name="T"/> delegate if successful.</returns>
|
||||
/// <exception cref="MissingMethodException">If the iCall could not be found.</exception>
|
||||
public static T GetICall<T>(string signature) where T : Delegate
|
||||
{
|
||||
if (iCallCache.ContainsKey(iCallName))
|
||||
return (T)iCallCache[iCallName];
|
||||
if (iCallCache.ContainsKey(signature))
|
||||
return (T)iCallCache[signature];
|
||||
|
||||
IntPtr ptr = il2cpp_resolve_icall(iCallName);
|
||||
IntPtr ptr = il2cpp_resolve_icall(signature);
|
||||
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
throw new MissingMethodException($"Could not resolve internal call by name '{iCallName}'!");
|
||||
throw new MissingMethodException($"Could not resolve internal call by name '{signature}'!");
|
||||
}
|
||||
|
||||
Delegate iCall = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
|
||||
iCallCache.Add(iCallName, iCall);
|
||||
iCallCache.Add(signature, iCall);
|
||||
|
||||
return (T)iCall;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
argLabelLayout.minHeight = 25;
|
||||
var argText = argLabelObj.GetComponent<Text>();
|
||||
var argTypeTxt = UISyntaxHighlight.ParseFullSyntax(arg.ParameterType, false);
|
||||
argText.text = $"{argTypeTxt} <color={UISyntaxHighlight.Local}>{arg.Name}</color>";
|
||||
argText.text = $"{argTypeTxt} <color={UISyntaxHighlight.LOCAL_ARG}>{arg.Name}</color>";
|
||||
|
||||
var argInputObj = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
|
||||
var argInputLayout = argInputObj.AddComponent<LayoutElement>();
|
||||
|
@ -168,7 +168,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
//var argLayout = argLabelObj.AddComponent<LayoutElement>();
|
||||
//argLayout.minWidth = 20;
|
||||
var argText = argLabelObj.GetComponent<Text>();
|
||||
argText.text = $"{constrainTxt} <color={UISyntaxHighlight.Enum}>{arg.Name}</color>";
|
||||
argText.text = $"{constrainTxt} <color={UISyntaxHighlight.CONST_VAR}>{arg.Name}</color>";
|
||||
|
||||
var argInputObj = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
|
||||
var argInputLayout = argInputObj.AddComponent<LayoutElement>();
|
||||
|
@ -8,36 +8,36 @@ namespace UnityExplorer.UI
|
||||
{
|
||||
public class UISyntaxHighlight
|
||||
{
|
||||
public const string Field_Static = "#8d8dc6";
|
||||
public const string Field_Instance = "#c266ff";
|
||||
public const string FIELD_STATIC = "#8d8dc6";
|
||||
public const string FIELD_INSTANCE = "#c266ff";
|
||||
|
||||
public const string Method_Static = "#b55b02";
|
||||
public const string Method_Instance = "#ff8000";
|
||||
public const string METHOD_STATIC = "#b55b02";
|
||||
public const string METHOD_INSTANCE = "#ff8000";
|
||||
|
||||
public const string Prop_Static = "#588075";
|
||||
public const string Prop_Instance = "#55a38e";
|
||||
public const string PROP_STATIC = "#588075";
|
||||
public const string PROP_INSTANCE = "#55a38e";
|
||||
|
||||
public const string Class_Static = "#3a8d71";
|
||||
public const string Class_Instance = "#2df7b2";
|
||||
public const string CLASS_STATIC = "#3a8d71";
|
||||
public const string CLASS_INSTANCE = "#2df7b2";
|
||||
|
||||
public const string Local = "#a6e9e9";
|
||||
public const string CLASS_STRUCT = "#0fba3a";
|
||||
|
||||
public const string StructGreen = "#0fba3a";
|
||||
public const string LOCAL_ARG = "#a6e9e9";
|
||||
|
||||
public static string Enum = "#92c470";
|
||||
public static string CONST_VAR = "#92c470";
|
||||
|
||||
internal static readonly Color s_silver = new Color(0.66f, 0.66f, 0.66f);
|
||||
|
||||
internal static string GetClassColor(Type type)
|
||||
{
|
||||
if (type.IsAbstract && type.IsSealed)
|
||||
return Class_Static;
|
||||
return CLASS_STATIC;
|
||||
else if (type.IsEnum || type.IsGenericParameter)
|
||||
return Enum;
|
||||
return CONST_VAR;
|
||||
else if (type.IsValueType)
|
||||
return StructGreen;
|
||||
return CLASS_STRUCT;
|
||||
else
|
||||
return Class_Instance;
|
||||
return CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
public static string ParseFullSyntax(Type type, bool includeNamespace, MemberInfo memberInfo = null)
|
||||
@ -49,7 +49,7 @@ namespace UnityExplorer.UI
|
||||
|
||||
if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter))
|
||||
{
|
||||
ret = $"<color={Enum}>{type.Name}</color>";
|
||||
ret = $"<color={CONST_VAR}>{type.Name}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -134,7 +134,7 @@ namespace UnityExplorer.UI
|
||||
|
||||
if (allGeneric)
|
||||
{
|
||||
args += $"<color={Enum}>{arg.Name}</color>";
|
||||
args += $"<color={CONST_VAR}>{arg.Name}</color>";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -153,30 +153,30 @@ namespace UnityExplorer.UI
|
||||
if (fi.IsStatic)
|
||||
{
|
||||
isStatic = true;
|
||||
memberColor = Field_Static;
|
||||
memberColor = FIELD_STATIC;
|
||||
}
|
||||
else
|
||||
memberColor = Field_Instance;
|
||||
memberColor = FIELD_INSTANCE;
|
||||
}
|
||||
else if (memberInfo is MethodInfo mi)
|
||||
{
|
||||
if (mi.IsStatic)
|
||||
{
|
||||
isStatic = true;
|
||||
memberColor = Method_Static;
|
||||
memberColor = METHOD_STATIC;
|
||||
}
|
||||
else
|
||||
memberColor = Method_Instance;
|
||||
memberColor = METHOD_INSTANCE;
|
||||
}
|
||||
else if (memberInfo is PropertyInfo pi)
|
||||
{
|
||||
if (pi.GetAccessors(true)[0].IsStatic)
|
||||
{
|
||||
isStatic = true;
|
||||
memberColor = Prop_Static;
|
||||
memberColor = PROP_STATIC;
|
||||
}
|
||||
else
|
||||
memberColor = Prop_Instance;
|
||||
memberColor = PROP_INSTANCE;
|
||||
}
|
||||
return memberColor;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user