mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-02 03:22:41 +08:00
Misc cleanups
This commit is contained in:
@ -16,7 +16,7 @@ namespace UnityExplorer.CSConsole
|
|||||||
"mscorlib", "System.Core", "System", "System.Xml"
|
"mscorlib", "System.Core", "System", "System.Xml"
|
||||||
};
|
};
|
||||||
|
|
||||||
internal static TextWriter _textWriter;
|
internal TextWriter _textWriter;
|
||||||
internal static StreamReportPrinter _reportPrinter;
|
internal static StreamReportPrinter _reportPrinter;
|
||||||
|
|
||||||
public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw))
|
public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw))
|
||||||
@ -51,8 +51,13 @@ namespace UnityExplorer.CSConsole
|
|||||||
ReferenceAssembly(asm);
|
ReferenceAssembly(asm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static CompilerContext context;
|
||||||
|
|
||||||
private static CompilerContext BuildContext(TextWriter tw)
|
private static CompilerContext BuildContext(TextWriter tw)
|
||||||
{
|
{
|
||||||
|
if (context != null)
|
||||||
|
return context;
|
||||||
|
|
||||||
_reportPrinter = new StreamReportPrinter(tw);
|
_reportPrinter = new StreamReportPrinter(tw);
|
||||||
|
|
||||||
var settings = new CompilerSettings
|
var settings = new CompilerSettings
|
||||||
@ -65,7 +70,7 @@ namespace UnityExplorer.CSConsole
|
|||||||
EnhancedWarnings = false
|
EnhancedWarnings = false
|
||||||
};
|
};
|
||||||
|
|
||||||
return new CompilerContext(settings, _reportPrinter);
|
return context = new CompilerContext(settings, _reportPrinter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ImportAppdomainAssemblies(Action<Assembly> import)
|
private static void ImportAppdomainAssemblies(Action<Assembly> import)
|
||||||
|
@ -14,9 +14,6 @@ namespace UnityExplorer.CacheObject
|
|||||||
{
|
{
|
||||||
public abstract class CacheMember : CacheObjectBase
|
public abstract class CacheMember : CacheObjectBase
|
||||||
{
|
{
|
||||||
//public ReflectionInspector ParentInspector { get; internal set; }
|
|
||||||
//public bool AutoUpdateWanted { get; internal set; }
|
|
||||||
|
|
||||||
public abstract Type DeclaringType { get; }
|
public abstract Type DeclaringType { get; }
|
||||||
public string NameForFiltering { get; protected set; }
|
public string NameForFiltering { get; protected set; }
|
||||||
public object DeclaringInstance => IsStatic ? null : (m_declaringInstance ?? (m_declaringInstance = Owner.Target.TryCast(DeclaringType)));
|
public object DeclaringInstance => IsStatic ? null : (m_declaringInstance ?? (m_declaringInstance = Owner.Target.TryCast(DeclaringType)));
|
||||||
@ -133,7 +130,6 @@ namespace UnityExplorer.CacheObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnEvaluateClicked()
|
public void OnEvaluateClicked()
|
||||||
{
|
{
|
||||||
if (!HasArguments)
|
if (!HasArguments)
|
||||||
|
@ -31,9 +31,6 @@ namespace UnityExplorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<Type> GetImplementationsOf(this Type baseType, bool allowAbstract, bool allowGeneric)
|
|
||||||
=> ReflectionUtility.GetImplementationsOf(baseType, allowAbstract, allowGeneric);
|
|
||||||
|
|
||||||
// ------- Misc extensions --------
|
// ------- Misc extensions --------
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -251,27 +251,25 @@ namespace UnityExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="baseType">The base type, which can optionally be abstract / interface.</param>
|
/// <param name="baseType">The base type, which can optionally be abstract / interface.</param>
|
||||||
/// <returns>All implementations of the type in the current AppDomain.</returns>
|
/// <returns>All implementations of the type in the current AppDomain.</returns>
|
||||||
public static HashSet<Type> GetImplementationsOf(Type baseType, bool allowAbstract, bool allowGeneric, bool allowRecursive = true)
|
public static HashSet<Type> GetImplementationsOf(Type baseType, bool allowAbstract, bool allowGeneric, bool allowEnum, bool allowRecursive = true)
|
||||||
{
|
{
|
||||||
var key = GetImplementationKey(baseType);
|
var key = GetImplementationKey(baseType);
|
||||||
|
|
||||||
int count = AllTypes.Count;
|
int count = AllTypes.Count;
|
||||||
HashSet<Type> ret;
|
HashSet<Type> ret;
|
||||||
if (!baseType.IsGenericParameter)
|
if (!baseType.IsGenericParameter)
|
||||||
ret = GetImplementations(key, baseType, allowAbstract, allowGeneric);
|
ret = GetImplementations(key, baseType, allowAbstract, allowGeneric, allowEnum);
|
||||||
else
|
else
|
||||||
ret = GetGenericParameterImplementations(key, baseType, allowAbstract, allowGeneric);
|
ret = GetGenericParameterImplementations(key, baseType, allowAbstract, allowGeneric);
|
||||||
|
|
||||||
// types were resolved during the parse, do it again if we're not already rebuilding.
|
// types were resolved during the parse, do it again if we're not already rebuilding.
|
||||||
if (allowRecursive && AllTypes.Count != count)
|
if (allowRecursive && AllTypes.Count != count)
|
||||||
{
|
|
||||||
ret = GetImplementationsOf(baseType, allowAbstract, allowGeneric, false);
|
ret = GetImplementationsOf(baseType, allowAbstract, allowGeneric, false);
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashSet<Type> GetImplementations(string key, Type baseType, bool allowAbstract, bool allowGeneric)
|
private static HashSet<Type> GetImplementations(string key, Type baseType, bool allowAbstract, bool allowGeneric, bool allowEnum)
|
||||||
{
|
{
|
||||||
if (!typeInheritance.ContainsKey(key))
|
if (!typeInheritance.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@ -287,7 +285,8 @@ namespace UnityExplorer
|
|||||||
if (set.Contains(type)
|
if (set.Contains(type)
|
||||||
|| (type.IsAbstract && type.IsSealed) // ignore static classes
|
|| (type.IsAbstract && type.IsSealed) // ignore static classes
|
||||||
|| (!allowAbstract && type.IsAbstract)
|
|| (!allowAbstract && type.IsAbstract)
|
||||||
|| (!allowGeneric && (type.IsGenericType || type.IsGenericTypeDefinition)))
|
|| (!allowGeneric && (type.IsGenericType || type.IsGenericTypeDefinition))
|
||||||
|
|| (!allowEnum && type.IsEnum))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (type.FullName.Contains("PrivateImplementationDetails")
|
if (type.FullName.Contains("PrivateImplementationDetails")
|
||||||
|
@ -56,6 +56,9 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public abstract int GetRootCount(Scene scene);
|
public abstract int GetRootCount(Scene scene);
|
||||||
|
|
||||||
|
public void SetColorBlockAuto(Selectable selectable, Color baseColor)
|
||||||
|
=> SetColorBlock(selectable, baseColor, baseColor * 1.2f, baseColor * 0.8f);
|
||||||
|
|
||||||
public abstract void SetColorBlock(Selectable selectable, ColorBlock colors);
|
public abstract void SetColorBlock(Selectable selectable, ColorBlock colors);
|
||||||
|
|
||||||
public abstract void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
public abstract void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
||||||
|
@ -102,7 +102,6 @@ namespace UnityExplorer.UI.Panels
|
|||||||
Rect.pivot = new Vector2(0f, 1f);
|
Rect.pivot = new Vector2(0f, 1f);
|
||||||
Rect.anchorMin = new Vector2(0.125f, 0.175f);
|
Rect.anchorMin = new Vector2(0.125f, 0.175f);
|
||||||
Rect.anchorMax = new Vector2(0.325f, 0.925f);
|
Rect.anchorMax = new Vector2(0.325f, 0.925f);
|
||||||
//mainPanelRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 350);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ConstructPanelContent()
|
public override void ConstructPanelContent()
|
||||||
|
@ -20,6 +20,8 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
|||||||
|
|
||||||
public Type BaseType { get; set; }
|
public Type BaseType { get; set; }
|
||||||
public Type[] GenericConstraints { get; set; }
|
public Type[] GenericConstraints { get; set; }
|
||||||
|
private bool allowAbstract;
|
||||||
|
private bool allowEnum;
|
||||||
|
|
||||||
public InputFieldRef InputField { get; }
|
public InputFieldRef InputField { get; }
|
||||||
public bool AnchorToCaretPosition => false;
|
public bool AnchorToCaretPosition => false;
|
||||||
@ -33,11 +35,16 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
|||||||
|
|
||||||
bool ISuggestionProvider.AllowNavigation => false;
|
bool ISuggestionProvider.AllowNavigation => false;
|
||||||
|
|
||||||
public TypeCompleter(Type baseType, InputFieldRef inputField)
|
public TypeCompleter(Type baseType, InputFieldRef inputField) : this(baseType, inputField, true, true) { }
|
||||||
|
|
||||||
|
public TypeCompleter(Type baseType, InputFieldRef inputField, bool allowAbstract, bool allowEnum)
|
||||||
{
|
{
|
||||||
BaseType = baseType;
|
BaseType = baseType;
|
||||||
InputField = inputField;
|
InputField = inputField;
|
||||||
|
|
||||||
|
this.allowAbstract = allowAbstract;
|
||||||
|
this.allowEnum = allowEnum;
|
||||||
|
|
||||||
inputField.OnValueChanged += OnInputFieldChanged;
|
inputField.OnValueChanged += OnInputFieldChanged;
|
||||||
|
|
||||||
if (BaseType != null)
|
if (BaseType != null)
|
||||||
@ -46,7 +53,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
|||||||
|
|
||||||
public void CacheTypes()
|
public void CacheTypes()
|
||||||
{
|
{
|
||||||
allowedTypes = ReflectionUtility.GetImplementationsOf(BaseType, true, false);
|
allowedTypes = ReflectionUtility.GetImplementationsOf(BaseType, allowAbstract, allowEnum, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSuggestionClicked(Suggestion suggestion)
|
public void OnSuggestionClicked(Suggestion suggestion)
|
||||||
|
Reference in New Issue
Block a user