diff --git a/src/CSConsole/ScriptEvaluator.cs b/src/CSConsole/ScriptEvaluator.cs index 3bcbaf4..58e4513 100644 --- a/src/CSConsole/ScriptEvaluator.cs +++ b/src/CSConsole/ScriptEvaluator.cs @@ -16,7 +16,7 @@ namespace UnityExplorer.CSConsole "mscorlib", "System.Core", "System", "System.Xml" }; - internal static TextWriter _textWriter; + internal TextWriter _textWriter; internal static StreamReportPrinter _reportPrinter; public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw)) @@ -51,8 +51,13 @@ namespace UnityExplorer.CSConsole ReferenceAssembly(asm); } + private static CompilerContext context; + private static CompilerContext BuildContext(TextWriter tw) { + if (context != null) + return context; + _reportPrinter = new StreamReportPrinter(tw); var settings = new CompilerSettings @@ -65,7 +70,7 @@ namespace UnityExplorer.CSConsole EnhancedWarnings = false }; - return new CompilerContext(settings, _reportPrinter); + return context = new CompilerContext(settings, _reportPrinter); } private static void ImportAppdomainAssemblies(Action import) diff --git a/src/CacheObject/CacheMember.cs b/src/CacheObject/CacheMember.cs index 9aaf101..4b529b5 100644 --- a/src/CacheObject/CacheMember.cs +++ b/src/CacheObject/CacheMember.cs @@ -14,9 +14,6 @@ namespace UnityExplorer.CacheObject { public abstract class CacheMember : CacheObjectBase { - //public ReflectionInspector ParentInspector { get; internal set; } - //public bool AutoUpdateWanted { get; internal set; } - public abstract Type DeclaringType { get; } public string NameForFiltering { get; protected set; } public object DeclaringInstance => IsStatic ? null : (m_declaringInstance ?? (m_declaringInstance = Owner.Target.TryCast(DeclaringType))); @@ -133,7 +130,6 @@ namespace UnityExplorer.CacheObject return false; } - public void OnEvaluateClicked() { if (!HasArguments) diff --git a/src/Core/Reflection/Extensions.cs b/src/Core/Reflection/Extensions.cs index 26b8f39..212c61f 100644 --- a/src/Core/Reflection/Extensions.cs +++ b/src/Core/Reflection/Extensions.cs @@ -31,9 +31,6 @@ namespace UnityExplorer } } - public static HashSet GetImplementationsOf(this Type baseType, bool allowAbstract, bool allowGeneric) - => ReflectionUtility.GetImplementationsOf(baseType, allowAbstract, allowGeneric); - // ------- Misc extensions -------- /// diff --git a/src/Core/Reflection/ReflectionUtility.cs b/src/Core/Reflection/ReflectionUtility.cs index d766b95..a63764e 100644 --- a/src/Core/Reflection/ReflectionUtility.cs +++ b/src/Core/Reflection/ReflectionUtility.cs @@ -251,27 +251,25 @@ namespace UnityExplorer /// /// The base type, which can optionally be abstract / interface. /// All implementations of the type in the current AppDomain. - public static HashSet GetImplementationsOf(Type baseType, bool allowAbstract, bool allowGeneric, bool allowRecursive = true) + public static HashSet GetImplementationsOf(Type baseType, bool allowAbstract, bool allowGeneric, bool allowEnum, bool allowRecursive = true) { var key = GetImplementationKey(baseType); int count = AllTypes.Count; HashSet ret; if (!baseType.IsGenericParameter) - ret = GetImplementations(key, baseType, allowAbstract, allowGeneric); + ret = GetImplementations(key, baseType, allowAbstract, allowGeneric, allowEnum); else ret = GetGenericParameterImplementations(key, baseType, allowAbstract, allowGeneric); // types were resolved during the parse, do it again if we're not already rebuilding. if (allowRecursive && AllTypes.Count != count) - { ret = GetImplementationsOf(baseType, allowAbstract, allowGeneric, false); - } return ret; } - private static HashSet GetImplementations(string key, Type baseType, bool allowAbstract, bool allowGeneric) + private static HashSet GetImplementations(string key, Type baseType, bool allowAbstract, bool allowGeneric, bool allowEnum) { if (!typeInheritance.ContainsKey(key)) { @@ -287,7 +285,8 @@ namespace UnityExplorer if (set.Contains(type) || (type.IsAbstract && type.IsSealed) // ignore static classes || (!allowAbstract && type.IsAbstract) - || (!allowGeneric && (type.IsGenericType || type.IsGenericTypeDefinition))) + || (!allowGeneric && (type.IsGenericType || type.IsGenericTypeDefinition)) + || (!allowEnum && type.IsEnum)) continue; if (type.FullName.Contains("PrivateImplementationDetails") diff --git a/src/Core/Runtime/RuntimeProvider.cs b/src/Core/Runtime/RuntimeProvider.cs index 2f6a098..d27336e 100644 --- a/src/Core/Runtime/RuntimeProvider.cs +++ b/src/Core/Runtime/RuntimeProvider.cs @@ -56,6 +56,9 @@ namespace UnityExplorer 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, Color? normal = null, Color? highlighted = null, Color? pressed = null, diff --git a/src/UI/Panels/ObjectExplorerPanel.cs b/src/UI/Panels/ObjectExplorerPanel.cs index 2ab8749..be3142a 100644 --- a/src/UI/Panels/ObjectExplorerPanel.cs +++ b/src/UI/Panels/ObjectExplorerPanel.cs @@ -102,7 +102,6 @@ namespace UnityExplorer.UI.Panels Rect.pivot = new Vector2(0f, 1f); Rect.anchorMin = new Vector2(0.125f, 0.175f); Rect.anchorMax = new Vector2(0.325f, 0.925f); - //mainPanelRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 350); } public override void ConstructPanelContent() diff --git a/src/UI/Widgets/AutoComplete/TypeCompleter.cs b/src/UI/Widgets/AutoComplete/TypeCompleter.cs index 8c69b95..ab77534 100644 --- a/src/UI/Widgets/AutoComplete/TypeCompleter.cs +++ b/src/UI/Widgets/AutoComplete/TypeCompleter.cs @@ -20,6 +20,8 @@ namespace UnityExplorer.UI.Widgets.AutoComplete public Type BaseType { get; set; } public Type[] GenericConstraints { get; set; } + private bool allowAbstract; + private bool allowEnum; public InputFieldRef InputField { get; } public bool AnchorToCaretPosition => false; @@ -33,11 +35,16 @@ namespace UnityExplorer.UI.Widgets.AutoComplete 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; InputField = inputField; + this.allowAbstract = allowAbstract; + this.allowEnum = allowEnum; + inputField.OnValueChanged += OnInputFieldChanged; if (BaseType != null) @@ -46,7 +53,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete public void CacheTypes() { - allowedTypes = ReflectionUtility.GetImplementationsOf(BaseType, true, false); + allowedTypes = ReflectionUtility.GetImplementationsOf(BaseType, allowAbstract, allowEnum, false); } public void OnSuggestionClicked(Suggestion suggestion)