From 16335c1bc47cf20b878cd9c1a826786c4b1a4d17 Mon Sep 17 00:00:00 2001 From: Sinai Date: Sat, 5 Jun 2021 19:36:09 +1000 Subject: [PATCH] Auto-cleanup --- src/Core/Config/ConfigManager.cs | 20 +++++----- src/Core/Input/CursorUnlocker.cs | 8 ++-- src/Core/Input/InputManager.cs | 4 +- src/Core/Input/InputSystem.cs | 4 +- src/Core/Reflection/Il2CppReflection.cs | 38 +++++++++---------- src/Core/Reflection/ReflectionUtility.cs | 16 ++++---- src/Core/Runtime/Mono/MonoProvider.cs | 2 +- src/Core/Tests/TestClass.cs | 14 +++---- src/Core/Utility/ParseUtility.cs | 6 +-- src/Core/Utility/SignatureHighlighter.cs | 14 +++---- src/Core/Utility/ToStringUtility.cs | 6 +-- src/ExplorerCore.cs | 10 ++--- src/Loader/BIE/BepInExConfigHandler.cs | 2 +- src/Loader/BIE/ExplorerBepInPlugin.cs | 8 ++-- src/UI/CSConsole/CSAutoCompleter.cs | 8 ++-- src/UI/CSConsole/ConsoleController.cs | 12 +++--- src/UI/CSConsole/Lexers/CommentLexer.cs | 2 +- src/UI/CSConsole/Lexers/KeywordLexer.cs | 10 ++--- src/UI/CSConsole/Lexers/Lexer.cs | 2 +- src/UI/CSConsole/ScriptEvaluator.cs | 4 +- src/UI/CSConsole/ScriptInteraction.cs | 10 ++--- src/UI/CacheObject/CacheKeyValuePair.cs | 2 +- src/UI/CacheObject/CacheListEntry.cs | 2 +- src/UI/CacheObject/CacheMember.cs | 10 ++--- src/UI/CacheObject/CacheObjectBase.cs | 12 +++--- src/UI/CacheObject/CacheProperty.cs | 2 +- src/UI/CacheObject/IValues/InteractiveEnum.cs | 2 +- src/UI/CacheObject/IValues/InteractiveList.cs | 6 +-- .../CacheObject/IValues/InteractiveString.cs | 8 ++-- .../IValues/InteractiveValueStruct.cs | 2 +- .../Views/CacheKeyValuePairCell.cs | 2 +- src/UI/CacheObject/Views/CacheObjectCell.cs | 2 +- src/UI/CacheObject/Views/EvaluateWidget.cs | 8 ++-- src/UI/Inspectors/GameObjectInspector.cs | 8 ++-- .../GameObjectWidgets/ComponentList.cs | 4 +- .../GameObjectWidgets/GameObjectControls.cs | 6 +-- src/UI/Inspectors/InspectUnderMouse.cs | 8 ++-- src/UI/Inspectors/InspectorManager.cs | 2 +- src/UI/Inspectors/InspectorTab.cs | 2 +- src/UI/Inspectors/ReflectionInspector.cs | 15 +++----- src/UI/Models/InputFieldRef.cs | 4 +- src/UI/ObjectExplorer/ObjectSearch.cs | 4 +- src/UI/ObjectExplorer/SceneExplorer.cs | 2 +- src/UI/ObjectExplorer/SceneHandler.cs | 4 +- src/UI/ObjectExplorer/SearchProvider.cs | 4 +- src/UI/Panels/InspectorPanel.cs | 2 +- src/UI/Panels/PanelDragger.cs | 10 ++--- src/UI/Panels/UIPanel.cs | 6 +-- src/UI/UIFactory.cs | 22 +++++------ src/UI/UIManager.cs | 2 +- .../Widgets/AutoComplete/AutoCompleteModal.cs | 6 +-- src/UI/Widgets/AutoSliderScrollbar.cs | 2 +- .../Widgets/ButtonList/ButtonListHandler.cs | 2 +- src/UI/Widgets/InputFieldScroller.cs | 4 +- src/UI/Widgets/ScrollPool/DataHeightCache.cs | 2 +- src/UI/Widgets/ScrollPool/ScrollPool.cs | 6 +-- .../Widgets/TransformTree/CachedTransform.cs | 8 ++-- 57 files changed, 194 insertions(+), 199 deletions(-) diff --git a/src/Core/Config/ConfigManager.cs b/src/Core/Config/ConfigManager.cs index 79f9471..de7990a 100644 --- a/src/Core/Config/ConfigManager.cs +++ b/src/Core/Config/ConfigManager.cs @@ -16,18 +16,18 @@ namespace UnityExplorer.Core.Config // See the UnityExplorer.Loader namespace for the implementations. public static ConfigHandler Handler { get; private set; } - public static ConfigElement Master_Toggle; + public static ConfigElement Master_Toggle; public static ConfigElement Main_Navbar_Anchor; - public static ConfigElement Force_Unlock_Mouse; - public static ConfigElement Force_Unlock_Toggle; - public static ConfigElement Aggressive_Mouse_Unlock; - public static ConfigElement Disable_EventSystem_Override; - public static ConfigElement Default_Output_Path; - public static ConfigElement Log_Unity_Debug; - public static ConfigElement Hide_On_Startup; - public static ConfigElement Startup_Delay_Time; + public static ConfigElement Force_Unlock_Mouse; + public static ConfigElement Force_Unlock_Toggle; + public static ConfigElement Aggressive_Mouse_Unlock; + public static ConfigElement Disable_EventSystem_Override; + public static ConfigElement Default_Output_Path; + public static ConfigElement Log_Unity_Debug; + public static ConfigElement Hide_On_Startup; + public static ConfigElement Startup_Delay_Time; - public static ConfigElement Reflection_Signature_Blacklist; + public static ConfigElement Reflection_Signature_Blacklist; // internal configs internal static InternalConfigHandler InternalHandler { get; private set; } diff --git a/src/Core/Input/CursorUnlocker.cs b/src/Core/Input/CursorUnlocker.cs index 3f823b9..429b22b 100644 --- a/src/Core/Input/CursorUnlocker.cs +++ b/src/Core/Input/CursorUnlocker.cs @@ -1,12 +1,12 @@ using System; +using System.Collections; using UnityEngine; using UnityEngine.EventSystems; -using UnityExplorer.Core.Input; -using BF = System.Reflection.BindingFlags; -using UnityExplorer.Core.Config; using UnityExplorer.Core; +using UnityExplorer.Core.Config; +using UnityExplorer.Core.Input; using UnityExplorer.UI; -using System.Collections; +using BF = System.Reflection.BindingFlags; namespace UnityExplorer.Core.Input diff --git a/src/Core/Input/InputManager.cs b/src/Core/Input/InputManager.cs index 65e7071..c0c4f13 100644 --- a/src/Core/Input/InputManager.cs +++ b/src/Core/Input/InputManager.cs @@ -1,6 +1,6 @@ using System; -using UnityEngine; using System.Diagnostics.CodeAnalysis; +using UnityEngine; using UnityEngine.EventSystems; namespace UnityExplorer.Core.Input @@ -74,7 +74,7 @@ namespace UnityExplorer.Core.Input ExplorerCore.Log("Initialized Legacy Input support"); return; } - catch + catch { // It's not working, we'll fall back to InputSystem. } diff --git a/src/Core/Input/InputSystem.cs b/src/Core/Input/InputSystem.cs index aa9e99f..ae09910 100644 --- a/src/Core/Input/InputSystem.cs +++ b/src/Core/Input/InputSystem.cs @@ -1,10 +1,10 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; using UnityEngine; using UnityEngine.EventSystems; using UnityExplorer.UI; -using System.Collections.Generic; -using System.Linq; namespace UnityExplorer.Core.Input { diff --git a/src/Core/Reflection/Il2CppReflection.cs b/src/Core/Reflection/Il2CppReflection.cs index e3c6aa1..3b9b809 100644 --- a/src/Core/Reflection/Il2CppReflection.cs +++ b/src/Core/Reflection/Il2CppReflection.cs @@ -37,7 +37,7 @@ namespace UnityExplorer $"deobfuscated types count: {DeobfuscatedTypes.Count}"); } - #region IL2CPP Extern and pointers +#region IL2CPP Extern and pointers // Extern C++ methods [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] @@ -63,10 +63,10 @@ namespace UnityExplorer return il2cppPtr != IntPtr.Zero; } - #endregion +#endregion - #region Deobfuscation cache +#region Deobfuscation cache private static readonly Dictionary DeobfuscatedTypes = new Dictionary(); private static readonly Dictionary reverseDeobCache = new Dictionary(); @@ -111,7 +111,7 @@ namespace UnityExplorer return theString; } - #endregion +#endregion // Get type by name @@ -124,7 +124,7 @@ namespace UnityExplorer return base.Internal_GetTypeByName(fullName); } - #region Get actual type +#region Get actual type internal override Type Internal_GetActualType(object obj) { @@ -183,10 +183,10 @@ namespace UnityExplorer return monoType; } - #endregion +#endregion - #region Casting +#region Casting private static readonly Dictionary cppClassPointers = new Dictionary(); @@ -278,10 +278,10 @@ namespace UnityExplorer // return il2cpp_class_is_assignable_from(thisTypePtr, fromTypePtr); //} - #endregion +#endregion - #region Boxing and unboxing ValueTypes +#region Boxing and unboxing ValueTypes // cached il2cpp unbox methods internal static readonly Dictionary unboxMethods = new Dictionary(); @@ -384,10 +384,10 @@ namespace UnityExplorer return cppStruct; } - #endregion +#endregion - #region String boxing/unboxing +#region String boxing/unboxing private const string IL2CPP_STRING_FULLNAME = "Il2CppSystem.String"; private const string STRING_FULLNAME = "System.String"; @@ -428,10 +428,10 @@ namespace UnityExplorer return s; } - #endregion +#endregion - #region Singleton finder +#region Singleton finder internal override void Internal_FindSingleton(string[] possibleNames, Type type, BF flags, List instances) { @@ -453,10 +453,10 @@ namespace UnityExplorer base.Internal_FindSingleton(possibleNames, type, flags, instances); } - #endregion +#endregion - #region Force-loading game modules +#region Force-loading game modules internal static string UnhollowedFolderPath => Path.GetFullPath( #if ML @@ -513,10 +513,10 @@ namespace UnityExplorer return false; } - #endregion +#endregion - #region Il2cpp reflection blacklist +#region Il2cpp reflection blacklist public override string[] DefaultReflectionBlacklist => defaultIl2CppBlacklist.ToArray(); @@ -665,10 +665,10 @@ namespace UnityExplorer "UnityEngine.XR.InputDevice.SendHapticImpulse", }; - #endregion +#endregion - #region IL2CPP IEnumerable and IDictionary +#region IL2CPP IEnumerable and IDictionary protected override bool Internal_TryGetEntryType(Type enumerableType, out Type type) { diff --git a/src/Core/Reflection/ReflectionUtility.cs b/src/Core/Reflection/ReflectionUtility.cs index 0549236..ac2fb21 100644 --- a/src/Core/Reflection/ReflectionUtility.cs +++ b/src/Core/Reflection/ReflectionUtility.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using BF = System.Reflection.BindingFlags; -using UnityExplorer.Core.Runtime; using System.Text; using UnityEngine; using UnityExplorer.Core.Config; +using UnityExplorer.Core.Runtime; +using BF = System.Reflection.BindingFlags; namespace UnityExplorer { @@ -225,7 +225,7 @@ namespace UnityExplorer return ret; } -#endregion + #endregion #region Type and Generic Parameter implementation cache @@ -360,7 +360,7 @@ namespace UnityExplorer return genericParameterInheritance[key]; } -#endregion + #endregion #region Internal MemberInfo Cache @@ -493,7 +493,7 @@ namespace UnityExplorer // Temp fix for IL2CPP until interface support improves - + // IsEnumerable public static bool IsEnumerable(Type type) => Instance.Internal_IsEnumerable(type); @@ -505,7 +505,7 @@ namespace UnityExplorer // TryGetEnumerator (list) - public static bool TryGetEnumerator(object list, out IEnumerator enumerator) + public static bool TryGetEnumerator(object list, out IEnumerator enumerator) => Instance.Internal_TryGetEnumerator(list, out enumerator); protected virtual bool Internal_TryGetEnumerator(object list, out IEnumerator enumerator) @@ -546,7 +546,7 @@ namespace UnityExplorer type = typeof(object); return false; } - + // IsDictionary public static bool IsDictionary(Type type) => Instance.Internal_IsDictionary(type); @@ -558,7 +558,7 @@ namespace UnityExplorer // TryGetEnumerator (dictionary) - public static bool TryGetDictEnumerator(object dictionary, out IEnumerator dictEnumerator) + public static bool TryGetDictEnumerator(object dictionary, out IEnumerator dictEnumerator) => Instance.Internal_TryGetDictEnumerator(dictionary, out dictEnumerator); protected virtual bool Internal_TryGetDictEnumerator(object dictionary, out IEnumerator dictEnumerator) diff --git a/src/Core/Runtime/Mono/MonoProvider.cs b/src/Core/Runtime/Mono/MonoProvider.cs index d6ace86..0084e99 100644 --- a/src/Core/Runtime/Mono/MonoProvider.cs +++ b/src/Core/Runtime/Mono/MonoProvider.cs @@ -143,7 +143,7 @@ public static class MonoExtensions { if (pi_childControlHeight == null) pi_childControlHeight = group.GetType().GetProperty("childControlHeight"); - + pi_childControlHeight?.SetValue(group, value, null); } diff --git a/src/Core/Tests/TestClass.cs b/src/Core/Tests/TestClass.cs index db82efe..de19d53 100644 --- a/src/Core/Tests/TestClass.cs +++ b/src/Core/Tests/TestClass.cs @@ -2,11 +2,11 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using UnityEngine; -using UnityExplorer.UI.CacheObject.IValues; -using System.Reflection; using UnityExplorer.UI; +using UnityExplorer.UI.CacheObject.IValues; #if CPP using UnhollowerRuntimeLib; using UnhollowerBaseLib; @@ -16,7 +16,7 @@ namespace UnityExplorer.Tests { public class TestIndexer : IList { - private readonly List list = new List() { 1,2,3,4,5 }; + private readonly List list = new List() { 1, 2, 3, 4, 5 }; public int Count => list.Count; public bool IsReadOnly => false; @@ -133,21 +133,21 @@ namespace UnityExplorer.Tests } } - private static void TestGeneric() + private static void TestGeneric() { ExplorerCore.Log("Test1 " + typeof(T).FullName); } - + private static void TestGenericClass() where T : class { ExplorerCore.Log("Test2 " + typeof(T).FullName); } - + private static void TestComponent() where T : Component { ExplorerCore.Log("Test3 " + typeof(T).FullName); } - + private static void TestStruct() where T : struct { ExplorerCore.Log("Test3 " + typeof(T).FullName); diff --git a/src/Core/Utility/ParseUtility.cs b/src/Core/Utility/ParseUtility.cs index da7a18a..bb1972c 100644 --- a/src/Core/Utility/ParseUtility.cs +++ b/src/Core/Utility/ParseUtility.cs @@ -22,7 +22,7 @@ namespace UnityExplorer public const string NUMBER_FORMAT = "0.####"; private static readonly Dictionary numSequenceStrings = new Dictionary(); - + // Helper for formatting float/double/decimal numbers to maximum of 4 decimal points. public static string FormatDecimalSequence(params object[] numbers) { @@ -100,7 +100,7 @@ namespace UnityExplorer obj = ReflectionUtility.GetMethodInfo(type, "Parse", ArgumentUtility.ParseArgs) .Invoke(null, new object[] { input }); } - + return true; } catch (Exception ex) @@ -148,7 +148,7 @@ namespace UnityExplorer } else return obj.ToString(); - + } catch (Exception ex) { diff --git a/src/Core/Utility/SignatureHighlighter.cs b/src/Core/Utility/SignatureHighlighter.cs index 8ae4c75..0b789a6 100644 --- a/src/Core/Utility/SignatureHighlighter.cs +++ b/src/Core/Utility/SignatureHighlighter.cs @@ -151,10 +151,10 @@ namespace UnityExplorer private static string HighlightType(Type type) { string key = type.ToString(); - + if (typeToRichType.ContainsKey(key)) return typeToRichType[key]; - + var sb = new StringBuilder(type.Name); bool isArray = false; @@ -212,7 +212,7 @@ namespace UnityExplorer { if (args.Length < 1) return string.Empty; - + var sb = new StringBuilder(); for (int i = 0; i < args.Length; i++) @@ -254,7 +254,7 @@ namespace UnityExplorer isStatic = true; return FIELD_STATIC; } - + return FIELD_INSTANCE; } else if (memberInfo is MethodInfo mi) @@ -264,7 +264,7 @@ namespace UnityExplorer isStatic = true; return METHOD_STATIC; } - + return METHOD_INSTANCE; } else if (memberInfo is PropertyInfo pi) @@ -274,7 +274,7 @@ namespace UnityExplorer isStatic = true; return PROP_STATIC; } - + return PROP_INSTANCE; } //else if (memberInfo is EventInfo ei) @@ -284,7 +284,7 @@ namespace UnityExplorer // isStatic = true; // return EVENT_STATIC; // } - + // return EVENT_INSTANCE; //} diff --git a/src/Core/Utility/ToStringUtility.cs b/src/Core/Utility/ToStringUtility.cs index 67be482..86df425 100644 --- a/src/Core/Utility/ToStringUtility.cs +++ b/src/Core/Utility/ToStringUtility.cs @@ -81,7 +81,7 @@ namespace UnityExplorer sb.Append(PruneString(obj.name, 50, 1)); sb.Append('"'); } - + AppendRichType(sb, richType); } else if (type.FullName.StartsWith(eventSystemNamespace)) @@ -93,8 +93,8 @@ namespace UnityExplorer { var toString = ToString(value); - if (type.IsGenericType - || toString == type.FullName + if (type.IsGenericType + || toString == type.FullName || toString == $"{type.FullName} {type.FullName}" || toString == $"Il2Cpp{type.FullName}" || type.FullName == $"Il2Cpp{toString}") { diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 98c9ef0..72fe530 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -103,15 +103,15 @@ namespace UnityExplorer RuntimeProvider.Instance.ProcessOnPostRender(); } -#region LOGGING + #region LOGGING - public static void Log(object message) + public static void Log(object message) => Log(message, LogType.Log); - public static void LogWarning(object message) + public static void LogWarning(object message) => Log(message, LogType.Warning); - public static void LogError(object message) + public static void LogError(object message) => Log(message, LogType.Error); public static void LogUnity(object message, LogType logType) @@ -146,6 +146,6 @@ namespace UnityExplorer } } -#endregion + #endregion } } diff --git a/src/Loader/BIE/BepInExConfigHandler.cs b/src/Loader/BIE/BepInExConfigHandler.cs index df8dd87..e0f631f 100644 --- a/src/Loader/BIE/BepInExConfigHandler.cs +++ b/src/Loader/BIE/BepInExConfigHandler.cs @@ -27,7 +27,7 @@ namespace UnityExplorer.Loader.BIE var entry = Config.Bind(CTG_NAME, config.Name, config.Value, new ConfigDescription(config.Description, null, tags)); - entry.SettingChanged += (object o, EventArgs e) => + entry.SettingChanged += (object o, EventArgs e) => { config.Value = entry.Value; }; diff --git a/src/Loader/BIE/ExplorerBepInPlugin.cs b/src/Loader/BIE/ExplorerBepInPlugin.cs index 79a866d..93ce63d 100644 --- a/src/Loader/BIE/ExplorerBepInPlugin.cs +++ b/src/Loader/BIE/ExplorerBepInPlugin.cs @@ -7,12 +7,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using UnityExplorer.Core.Config; -using UnityExplorer.Loader.BIE; using UnityEngine; -using UnityExplorer.Core; using UnityEngine.EventSystems; +using UnityExplorer.Core; +using UnityExplorer.Core.Config; using UnityExplorer.Core.Input; +using UnityExplorer.Loader.BIE; #if CPP using BepInEx.IL2CPP; using UnhollowerRuntimeLib; @@ -50,7 +50,7 @@ namespace UnityExplorer public Action OnLogMessage => LogSource.LogMessage; public Action OnLogWarning => LogSource.LogWarning; - public Action OnLogError => LogSource.LogError; + public Action OnLogError => LogSource.LogError; // Init common to Mono and Il2Cpp internal void UniversalInit() diff --git a/src/UI/CSConsole/CSAutoCompleter.cs b/src/UI/CSConsole/CSAutoCompleter.cs index c0f60c7..a760f1b 100644 --- a/src/UI/CSConsole/CSAutoCompleter.cs +++ b/src/UI/CSConsole/CSAutoCompleter.cs @@ -22,7 +22,6 @@ namespace UnityExplorer.UI.CSConsole AutoCompleteModal.Instance.ReleaseOwnership(this); } - // Delimiters for completions, notably does not include '.' private readonly HashSet delimiters = new HashSet { '{', '}', ',', ';', '<', '>', '(', ')', '[', ']', '=', '|', '&', '?' @@ -67,11 +66,10 @@ namespace UnityExplorer.UI.CSConsole } string input = InputField.Text.Substring(startIdx, caret - startIdx + 1); - // Get MCS completions string[] evaluatorCompletions = ConsoleController.Evaluator.GetCompletions(input, out string prefix); - + if (evaluatorCompletions != null && evaluatorCompletions.Any()) { suggestions.AddRange(from completion in evaluatorCompletions @@ -100,7 +98,7 @@ namespace UnityExplorer.UI.CSConsole { if (!keywordHighlights.ContainsKey(kw)) keywordHighlights.Add(kw, $"{kw}"); - + string completion = kw.Substring(input.Length, kw.Length - input.Length); suggestions.Add(new Suggestion(keywordHighlights[kw], completion)); } @@ -124,7 +122,7 @@ namespace UnityExplorer.UI.CSConsole private readonly StringBuilder highlightBuilder = new StringBuilder(); private const string OPEN_HIGHLIGHT = ""; - + private string GetHighlightString(string prefix, string completion) { highlightBuilder.Clear(); diff --git a/src/UI/CSConsole/ConsoleController.cs b/src/UI/CSConsole/ConsoleController.cs index a17aa5a..aba3c4d 100644 --- a/src/UI/CSConsole/ConsoleController.cs +++ b/src/UI/CSConsole/ConsoleController.cs @@ -1,18 +1,18 @@ -using System; +using Mono.CSharp; +using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; -using UnityExplorer.UI.CSConsole; using UnityExplorer.Core.Input; +using UnityExplorer.UI.CSConsole; using UnityExplorer.UI.Panels; using UnityExplorer.UI.Widgets.AutoComplete; -using System.Reflection; -using Mono.CSharp; namespace UnityExplorer.UI.CSConsole { @@ -221,7 +221,7 @@ namespace UnityExplorer.UI.CSConsole if (InputManager.GetKeyDown(KeyCode.Escape)) { Input.Text = previousInput; - + if (EnableSuggestions && AutoCompleteModal.CheckEscape(Completer)) OnAutocompleteEscaped(); @@ -240,7 +240,7 @@ namespace UnityExplorer.UI.CSConsole } var inStringOrComment = HighlightVisibleInput(); - + if (!settingCaretCoroutine) { if (EnableSuggestions) diff --git a/src/UI/CSConsole/Lexers/CommentLexer.cs b/src/UI/CSConsole/Lexers/CommentLexer.cs index e4c541e..ed33565 100644 --- a/src/UI/CSConsole/Lexers/CommentLexer.cs +++ b/src/UI/CSConsole/Lexers/CommentLexer.cs @@ -44,7 +44,7 @@ namespace UnityExplorer.UI.CSConsole.Lexers while (!lexer.EndOfInput && !(lexer.Current == '/' && lexer.Previous == '*')); return true; - } + } } return false; diff --git a/src/UI/CSConsole/Lexers/KeywordLexer.cs b/src/UI/CSConsole/Lexers/KeywordLexer.cs index 10f8892..5c55ebb 100644 --- a/src/UI/CSConsole/Lexers/KeywordLexer.cs +++ b/src/UI/CSConsole/Lexers/KeywordLexer.cs @@ -12,12 +12,12 @@ namespace UnityExplorer.UI.CSConsole.Lexers public static readonly HashSet keywords = new HashSet { // reserved keywords -"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", +"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", -"fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", -"long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", -"readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", -"this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", +"fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", +"long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", +"readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", +"this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", // contextual keywords "add", "and", "alias", "ascending", "async", "await", "by", "descending", "dynamic", "equals", "from", "get", diff --git a/src/UI/CSConsole/Lexers/Lexer.cs b/src/UI/CSConsole/Lexers/Lexer.cs index a7adf58..a0a5a92 100644 --- a/src/UI/CSConsole/Lexers/Lexer.cs +++ b/src/UI/CSConsole/Lexers/Lexer.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using UnityEngine; using System.Linq; +using UnityEngine; namespace UnityExplorer.UI.CSConsole.Lexers { diff --git a/src/UI/CSConsole/ScriptEvaluator.cs b/src/UI/CSConsole/ScriptEvaluator.cs index f5f6b51..d849b07 100644 --- a/src/UI/CSConsole/ScriptEvaluator.cs +++ b/src/UI/CSConsole/ScriptEvaluator.cs @@ -1,9 +1,9 @@ -using System; +using Mono.CSharp; +using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; -using Mono.CSharp; // Thanks to ManlyMarco for this diff --git a/src/UI/CSConsole/ScriptInteraction.cs b/src/UI/CSConsole/ScriptInteraction.cs index 340a955..faf432b 100644 --- a/src/UI/CSConsole/ScriptInteraction.cs +++ b/src/UI/CSConsole/ScriptInteraction.cs @@ -1,11 +1,11 @@ -using System; -using Mono.CSharp; +using Mono.CSharp; +using System; using System.Collections; -using UnityEngine; using System.Collections.Generic; using System.Linq; -using UnityExplorer.Core.Runtime; using System.Text; +using UnityEngine; +using UnityExplorer.Core.Runtime; /* Welcome to the UnityExplorer C# Console! @@ -58,7 +58,7 @@ namespace UnityExplorer.UI.CSConsole public static void GetClasses() { if (ReflectionUtility.GetFieldInfo(typeof(Evaluator), "source_file") - .GetValue(Evaluator) is CompilationSourceFile sourceFile + .GetValue(Evaluator) is CompilationSourceFile sourceFile && sourceFile.Containers.Any()) { var sb = new StringBuilder(); diff --git a/src/UI/CacheObject/CacheKeyValuePair.cs b/src/UI/CacheObject/CacheKeyValuePair.cs index 7f97afb..45c979d 100644 --- a/src/UI/CacheObject/CacheKeyValuePair.cs +++ b/src/UI/CacheObject/CacheKeyValuePair.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using UnityExplorer.UI.CacheObject.Views; using UnityExplorer.UI.CacheObject.IValues; +using UnityExplorer.UI.CacheObject.Views; namespace UnityExplorer.UI.CacheObject { diff --git a/src/UI/CacheObject/CacheListEntry.cs b/src/UI/CacheObject/CacheListEntry.cs index 0fdfef4..eae6658 100644 --- a/src/UI/CacheObject/CacheListEntry.cs +++ b/src/UI/CacheObject/CacheListEntry.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using UnityExplorer.UI.CacheObject.Views; using UnityExplorer.UI.CacheObject.IValues; +using UnityExplorer.UI.CacheObject.Views; namespace UnityExplorer.UI.CacheObject { diff --git a/src/UI/CacheObject/CacheMember.cs b/src/UI/CacheObject/CacheMember.cs index 5c7f10f..be8cc82 100644 --- a/src/UI/CacheObject/CacheMember.cs +++ b/src/UI/CacheObject/CacheMember.cs @@ -15,7 +15,7 @@ namespace UnityExplorer.UI.CacheObject { //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))); @@ -27,7 +27,7 @@ namespace UnityExplorer.UI.CacheObject public Type[] GenericArguments { get; protected set; } = ArgumentUtility.EmptyTypes; public EvaluateWidget Evaluator { get; protected set; } public bool Evaluating => Evaluator != null && Evaluator.UIRoot.activeSelf; - + public virtual void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member) { this.Owner = inspector; @@ -234,7 +234,7 @@ namespace UnityExplorer.UI.CacheObject return sorted; } - private static void TryCacheMember(MemberInfo member, List list, HashSet cachedSigs, + private static void TryCacheMember(MemberInfo member, List list, HashSet cachedSigs, Type declaringType, ReflectionInspector _inspector, bool ignorePropertyMethodInfos = true) { try @@ -253,7 +253,7 @@ namespace UnityExplorer.UI.CacheObject case MemberTypes.Method: { var mi = member as MethodInfo; - if (ignorePropertyMethodInfos + if (ignorePropertyMethodInfos && (mi.Name.StartsWith("get_") || mi.Name.StartsWith("set_"))) return; @@ -322,7 +322,7 @@ namespace UnityExplorer.UI.CacheObject } } - internal static string GetSig(MemberInfo member) + internal static string GetSig(MemberInfo member) => $"{member.DeclaringType.Name}.{member.Name}"; internal static string GetArgumentString(ParameterInfo[] args) diff --git a/src/UI/CacheObject/CacheObjectBase.cs b/src/UI/CacheObject/CacheObjectBase.cs index 02d57a2..8d6a53b 100644 --- a/src/UI/CacheObject/CacheObjectBase.cs +++ b/src/UI/CacheObject/CacheObjectBase.cs @@ -7,8 +7,8 @@ using System.Text; using UnityEngine; using UnityEngine.UI; using UnityExplorer.Core.Runtime; -using UnityExplorer.UI.CacheObject.Views; using UnityExplorer.UI.CacheObject.IValues; +using UnityExplorer.UI.CacheObject.Views; using UnityExplorer.UI.Models; namespace UnityExplorer.UI.CacheObject @@ -180,8 +180,8 @@ namespace UnityExplorer.UI.CacheObject return ValueState.Enum; else if (type == typeof(Color) || type == typeof(Color32)) return ValueState.Color; - else if (InteractiveValueStruct.SupportsType(type)) - return ValueState.ValueStruct; + else if (InteractiveValueStruct.SupportsType(type)) + return ValueState.ValueStruct; else if (ReflectionUtility.IsDictionary(type)) return ValueState.Dictionary; else if (!typeof(Transform).IsAssignableFrom(type) && ReflectionUtility.IsEnumerable(type)) @@ -197,7 +197,7 @@ namespace UnityExplorer.UI.CacheObject switch (State) { case ValueState.NotEvaluated: - return $"{NOT_YET_EVAL} ({SignatureHighlighter.Parse(FallbackType, true)})"; + return $"{NOT_YET_EVAL} ({SignatureHighlighter.Parse(FallbackType, true)})"; case ValueState.Exception: return $"{LastException.ReflectionExToString()}"; @@ -221,7 +221,7 @@ namespace UnityExplorer.UI.CacheObject return $"\"{ToStringUtility.PruneString(s, 200, 5)}\""; } break; - + // try to prefix the count of the collection for lists and dicts case ValueState.Collection: if (!LastValueWasNull) @@ -263,7 +263,7 @@ namespace UnityExplorer.UI.CacheObject cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted); if (IValue != null) - { + { IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false); IValue.SetLayout(); } diff --git a/src/UI/CacheObject/CacheProperty.cs b/src/UI/CacheObject/CacheProperty.cs index 688f88d..503ae95 100644 --- a/src/UI/CacheObject/CacheProperty.cs +++ b/src/UI/CacheObject/CacheProperty.cs @@ -31,7 +31,7 @@ namespace UnityExplorer.UI.CacheObject object ret; if (HasArguments) ret = PropertyInfo.GetValue(DeclaringInstance, this.Evaluator.TryParseArguments()); - else + else ret = PropertyInfo.GetValue(DeclaringInstance, null); HadException = false; LastException = null; diff --git a/src/UI/CacheObject/IValues/InteractiveEnum.cs b/src/UI/CacheObject/IValues/InteractiveEnum.cs index e2f643d..3c1d61a 100644 --- a/src/UI/CacheObject/IValues/InteractiveEnum.cs +++ b/src/UI/CacheObject/IValues/InteractiveEnum.cs @@ -20,7 +20,7 @@ namespace UnityExplorer.UI.CacheObject.IValues public CachedEnumValue ValueAtIdx(int idx) => (CachedEnumValue)CurrentValues[idx]; public CachedEnumValue ValueAtKey(object key) => (CachedEnumValue)CurrentValues[key]; - + private Dropdown enumDropdown; private GameObject toggleHolder; private readonly List flagToggles = new List(); diff --git a/src/UI/CacheObject/IValues/InteractiveList.cs b/src/UI/CacheObject/IValues/InteractiveList.cs index 88c27fe..85b93ec 100644 --- a/src/UI/CacheObject/IValues/InteractiveList.cs +++ b/src/UI/CacheObject/IValues/InteractiveList.cs @@ -206,7 +206,7 @@ namespace UnityExplorer.UI.CacheObject.IValues { ExplorerCore.LogWarning($"Exception setting IList value: {ex}"); } - } + } // List entry scroll pool @@ -254,8 +254,8 @@ namespace UnityExplorer.UI.CacheObject.IValues ListScrollPool.Initialize(this, SetLayout); scrollLayout = scrollObj.GetComponent(); - NotSupportedLabel = UIFactory.CreateLabel(ListScrollPool.Content.gameObject, "NotSupportedMessage", - "The IEnumerable failed to enumerate. This is likely due to an issue with Unhollowed interfaces.", + NotSupportedLabel = UIFactory.CreateLabel(ListScrollPool.Content.gameObject, "NotSupportedMessage", + "The IEnumerable failed to enumerate. This is likely due to an issue with Unhollowed interfaces.", TextAnchor.MiddleLeft, Color.red); UIFactory.SetLayoutElement(NotSupportedLabel.gameObject, minHeight: 25, flexibleWidth: 9999); diff --git a/src/UI/CacheObject/IValues/InteractiveString.cs b/src/UI/CacheObject/IValues/InteractiveString.cs index 3ea426e..5c240d1 100644 --- a/src/UI/CacheObject/IValues/InteractiveString.cs +++ b/src/UI/CacheObject/IValues/InteractiveString.cs @@ -18,7 +18,7 @@ namespace UnityExplorer.UI.CacheObject.IValues public InputFieldRef inputField; public ButtonRef ApplyButton; - + public GameObject SaveFileRow; public InputFieldRef SaveFilePath; @@ -36,7 +36,7 @@ namespace UnityExplorer.UI.CacheObject.IValues { if (s == null) return false; - + return s.Length >= UIManager.MAX_INPUTFIELD_CHARS; } @@ -83,7 +83,7 @@ namespace UnityExplorer.UI.CacheObject.IValues if (File.Exists(path)) File.Delete(path); - + File.WriteAllText(path, RealValue); } @@ -98,7 +98,7 @@ namespace UnityExplorer.UI.CacheObject.IValues UIFactory.SetLayoutElement(SaveFileRow, flexibleWidth: 9999); UIFactory.SetLayoutGroup(SaveFileRow, false, true, true, true, 3); - UIFactory.CreateLabel(SaveFileRow, "Info", "String is too long! Save to file if you want to see the full string.", + UIFactory.CreateLabel(SaveFileRow, "Info", "String is too long! Save to file if you want to see the full string.", TextAnchor.MiddleLeft); var horizRow = UIFactory.CreateUIObject("Horiz", SaveFileRow); diff --git a/src/UI/CacheObject/IValues/InteractiveValueStruct.cs b/src/UI/CacheObject/IValues/InteractiveValueStruct.cs index a414014..e8ec2c9 100644 --- a/src/UI/CacheObject/IValues/InteractiveValueStruct.cs +++ b/src/UI/CacheObject/IValues/InteractiveValueStruct.cs @@ -143,7 +143,7 @@ namespace UnityExplorer.UI.CacheObject.IValues ExplorerCore.LogWarning("Exception setting value: " + ex); } } - + // UI Setup for type private void SetupUIForType() diff --git a/src/UI/CacheObject/Views/CacheKeyValuePairCell.cs b/src/UI/CacheObject/Views/CacheKeyValuePairCell.cs index ae2599a..bc7ba67 100644 --- a/src/UI/CacheObject/Views/CacheKeyValuePairCell.cs +++ b/src/UI/CacheObject/Views/CacheKeyValuePairCell.cs @@ -4,8 +4,8 @@ using System.Linq; using System.Text; using UnityEngine; using UnityEngine.UI; -using UnityExplorer.UI.Inspectors; using UnityExplorer.UI.CacheObject.IValues; +using UnityExplorer.UI.Inspectors; using UnityExplorer.UI.Widgets; namespace UnityExplorer.UI.CacheObject.Views diff --git a/src/UI/CacheObject/Views/CacheObjectCell.cs b/src/UI/CacheObject/Views/CacheObjectCell.cs index a13e5ea..d247549 100644 --- a/src/UI/CacheObject/Views/CacheObjectCell.cs +++ b/src/UI/CacheObject/Views/CacheObjectCell.cs @@ -4,8 +4,8 @@ using System.Linq; using System.Text; using UnityEngine; using UnityEngine.UI; -using UnityExplorer.UI.Inspectors; using UnityExplorer.UI.CacheObject.IValues; +using UnityExplorer.UI.Inspectors; using UnityExplorer.UI.Widgets; namespace UnityExplorer.UI.CacheObject.Views diff --git a/src/UI/CacheObject/Views/EvaluateWidget.cs b/src/UI/CacheObject/Views/EvaluateWidget.cs index 8896aea..f0aa36e 100644 --- a/src/UI/CacheObject/Views/EvaluateWidget.cs +++ b/src/UI/CacheObject/Views/EvaluateWidget.cs @@ -67,7 +67,7 @@ namespace UnityExplorer.UI.CacheObject.Views for (int i = 0; i < genericArguments.Length; i++) { - outArgs[i] = ReflectionUtility.GetTypeByName(genericInput[i]) + outArgs[i] = ReflectionUtility.GetTypeByName(genericInput[i]) ?? throw new Exception($"Could not find any type by name '{genericInput[i]}'!"); } @@ -206,7 +206,7 @@ namespace UnityExplorer.UI.CacheObject.Views var elemType = arg.ParameterType; if (elemType.IsByRef) elemType = elemType.GetElementType(); - argInputFields[i].PlaceholderText.text = $"eg. {ParseUtility.GetExampleInput(elemType)}"; + argInputFields[i].PlaceholderText.text = $"eg. {ParseUtility.GetExampleInput(elemType)}"; } } } @@ -249,7 +249,7 @@ namespace UnityExplorer.UI.CacheObject.Views public GameObject CreateContent(GameObject parent) { - UIRoot = UIFactory.CreateVerticalGroup(parent, "EvaluateWidget", false, false, true, true, 3, new Vector4(2, 2, 2, 2), + UIRoot = UIFactory.CreateVerticalGroup(parent, "EvaluateWidget", false, false, true, true, 3, new Vector4(2, 2, 2, 2), new Color(0.15f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(UIRoot, minWidth: 50, flexibleWidth: 9999, minHeight: 50, flexibleHeight: 800); //UIRoot.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize; @@ -275,7 +275,7 @@ namespace UnityExplorer.UI.CacheObject.Views // evaluate button var evalButton = UIFactory.CreateButton(UIRoot, "EvaluateButton", "Evaluate", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(evalButton.Component.gameObject, minHeight: 25, minWidth: 150, flexibleWidth: 0); - evalButton.OnClick += () => + evalButton.OnClick += () => { Owner.EvaluateAndSetCell(); }; diff --git a/src/UI/Inspectors/GameObjectInspector.cs b/src/UI/Inspectors/GameObjectInspector.cs index 54b6b8e..c89d918 100644 --- a/src/UI/Inspectors/GameObjectInspector.cs +++ b/src/UI/Inspectors/GameObjectInspector.cs @@ -208,7 +208,7 @@ namespace UnityExplorer.UI.Inspectors TransformTree.RefreshData(true, false); } - + private void OnAddComponentClicked(string input) { if (ReflectionUtility.AllTypes.TryGetValue(input, out Type type)) @@ -234,10 +234,10 @@ namespace UnityExplorer.UI.Inspectors public override GameObject CreateContent(GameObject parent) { - UIRoot = UIFactory.CreateVerticalGroup(parent, "GameObjectInspector", true, false, true, true, 5, + UIRoot = UIFactory.CreateVerticalGroup(parent, "GameObjectInspector", true, false, true, true, 5, new Vector4(4, 4, 4, 4), new Color(0.065f, 0.065f, 0.065f)); - var scrollObj = UIFactory.CreateScrollView(UIRoot, "GameObjectInspector", out Content, out var scrollbar, + var scrollObj = UIFactory.CreateScrollView(UIRoot, "GameObjectInspector", out Content, out var scrollbar, new Color(0.065f, 0.065f, 0.065f)); UIFactory.SetLayoutElement(scrollObj, minHeight: 250, preferredHeight: 300, flexibleHeight: 0, flexibleWidth: 9999); @@ -245,7 +245,7 @@ namespace UnityExplorer.UI.Inspectors // Construct GO Controls GOControls = new GameObjectControls(this); - + ConstructLists(); return UIRoot; diff --git a/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs b/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs index 538e503..e9b9f08 100644 --- a/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs +++ b/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs @@ -11,7 +11,7 @@ namespace UnityExplorer.UI.Inspectors { public GameObjectInspector Parent; - public ComponentList(ScrollPool scrollPool, Func> getEntriesMethod) + public ComponentList(ScrollPool scrollPool, Func> getEntriesMethod) : base(scrollPool, getEntriesMethod, null, null, null) { base.SetICell = SetComponentCell; @@ -112,7 +112,7 @@ namespace UnityExplorer.UI.Inspectors cell.BehaviourToggle.interactable = false; cell.BehaviourToggle.Set(true, false); //RuntimeProvider.Instance.SetColorBlock(cell.BehaviourToggle,) - cell.BehaviourToggle.graphic.color = new Color(0.2f, 0.2f, 0.2f); + cell.BehaviourToggle.graphic.color = new Color(0.2f, 0.2f, 0.2f); } // if component is the first index it must be the transform, dont show Destroy button for it. diff --git a/src/UI/Inspectors/GameObjectWidgets/GameObjectControls.cs b/src/UI/Inspectors/GameObjectWidgets/GameObjectControls.cs index 6d1b29f..7b8ade0 100644 --- a/src/UI/Inspectors/GameObjectWidgets/GameObjectControls.cs +++ b/src/UI/Inspectors/GameObjectWidgets/GameObjectControls.cs @@ -186,7 +186,7 @@ namespace UnityExplorer.UI.Inspectors if (parentToSet) DoSetParent(parentToSet); else - { + { ExplorerCore.LogWarning($"Could not find any GameObject name or path '{input}'!"); UpdateGameObjectInfo(false, true); } @@ -442,7 +442,7 @@ namespace UnityExplorer.UI.Inspectors private void ConstructTopInfo() { - var topInfoHolder = UIFactory.CreateVerticalGroup(Parent.Content, "TopInfoHolder", false, false, true, true, 3, + var topInfoHolder = UIFactory.CreateVerticalGroup(Parent.Content, "TopInfoHolder", false, false, true, true, 3, new Vector4(3, 3, 3, 3), new Color(0.1f, 0.1f, 0.1f), TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(topInfoHolder, minHeight: 100, flexibleWidth: 9999); topInfoHolder.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize; @@ -575,7 +575,7 @@ namespace UnityExplorer.UI.Inspectors var flagsDrop = UIFactory.CreateDropdown(thirdrow, out FlagsDropdown, "None", 14, OnFlagsDropdownChanged); FlagsDropdown.captionText.color = SignatureHighlighter.EnumGreen; UIFactory.SetLayoutElement(flagsDrop, minHeight: 25, minWidth: 135, flexibleWidth: 999); - if (hideFlagsValues == null) + if (hideFlagsValues == null) GetHideFlagNames(); foreach (var name in hideFlagsValues.Keys) FlagsDropdown.options.Add(new Dropdown.OptionData(name)); diff --git a/src/UI/Inspectors/InspectUnderMouse.cs b/src/UI/Inspectors/InspectUnderMouse.cs index d7bd539..fb9ea23 100644 --- a/src/UI/Inspectors/InspectUnderMouse.cs +++ b/src/UI/Inspectors/InspectUnderMouse.cs @@ -68,8 +68,8 @@ namespace UnityExplorer.UI.Inspectors { MainCamera = Camera.main; if (!MainCamera) - return; - + return; + PanelDragger.ForceEnd(); Mode = mode; @@ -95,8 +95,8 @@ namespace UnityExplorer.UI.Inspectors Inspecting = false; UIManager.NavBarRect.gameObject.SetActive(true); - UIManager.PanelHolder.SetActive(true); - + UIManager.PanelHolder.SetActive(true); + var drop = UIManager.MouseInspectDropdown; if (drop.transform.Find("Dropdown List") is Transform list) drop.DestroyDropdownList(list.gameObject); diff --git a/src/UI/Inspectors/InspectorManager.cs b/src/UI/Inspectors/InspectorManager.cs index e6eda65..fa403b0 100644 --- a/src/UI/Inspectors/InspectorManager.cs +++ b/src/UI/Inspectors/InspectorManager.cs @@ -87,7 +87,7 @@ namespace UnityExplorer } } - private static void CreateInspector(object target, bool staticReflection = false, + private static void CreateInspector(object target, bool staticReflection = false, CacheObjectBase sourceCache = null) where T : InspectorBase { var inspector = Pool.Borrow(); diff --git a/src/UI/Inspectors/InspectorTab.cs b/src/UI/Inspectors/InspectorTab.cs index 045dfa0..16fc418 100644 --- a/src/UI/Inspectors/InspectorTab.cs +++ b/src/UI/Inspectors/InspectorTab.cs @@ -33,7 +33,7 @@ namespace UnityExplorer.UI.Inspectors public GameObject CreateContent(GameObject parent) { - UIRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", false, true, true, true, 0, + UIRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", false, true, true, true, 0, default, new Color(0.13f, 0.13f, 0.13f), childAlignment: TextAnchor.MiddleLeft); UIFactory.SetLayoutElement(UIRoot, minWidth: 200, flexibleWidth: 0); UIRoot.AddComponent(); diff --git a/src/UI/Inspectors/ReflectionInspector.cs b/src/UI/Inspectors/ReflectionInspector.cs index 881105e..fd9817e 100644 --- a/src/UI/Inspectors/ReflectionInspector.cs +++ b/src/UI/Inspectors/ReflectionInspector.cs @@ -54,6 +54,7 @@ namespace UnityExplorer.UI.Inspectors private readonly Color disabledButtonColor = new Color(0.24f, 0.24f, 0.24f); private readonly Color enabledButtonColor = new Color(0.2f, 0.27f, 0.2f); + private readonly Dictionary scopeFilterButtons = new Dictionary(); private readonly List memberTypeToggles = new List(); private InputFieldRef filterInputField; @@ -73,7 +74,6 @@ namespace UnityExplorer.UI.Inspectors private IEnumerator InitCoroutine() { yield return null; - LayoutRebuilder.ForceRebuildLayoutImmediate(InspectorPanel.Instance.ContentRect); } @@ -142,7 +142,7 @@ namespace UnityExplorer.UI.Inspectors // reset filters this.filterInputField.Text = ""; - + SetFilter("", StaticOnly ? BindingFlags.Static : BindingFlags.Instance); scopeFilterButtons[BindingFlags.Default].Component.gameObject.SetActive(!StaticOnly); scopeFilterButtons[BindingFlags.Instance].Component.gameObject.SetActive(!StaticOnly); @@ -307,11 +307,8 @@ namespace UnityExplorer.UI.Inspectors private void CalculateLayouts() { - // Calculate sizes - LeftGroupWidth = (int)Math.Max(200, (0.4f * InspectorManager.PanelWidth) - 5);// Math.Min(450f, 0.4f * InspectorManager.PanelWidth - 5)); + LeftGroupWidth = (int)Math.Max(200, (0.4f * InspectorManager.PanelWidth) - 5); RightGroupWidth = (int)Math.Max(200, InspectorManager.PanelWidth - LeftGroupWidth - 65); - - //memberTitleLayout.minWidth = LeftGroupWidth; } private void SetCellLayout(CacheObjectCell cell) @@ -342,7 +339,7 @@ namespace UnityExplorer.UI.Inspectors ConstructUnityObjectRow(); - mainContentHolder = UIFactory.CreateVerticalGroup(UIRoot, "MemberHolder", false, false, true, true, 5, new Vector4(2,2,2,2), + mainContentHolder = UIFactory.CreateVerticalGroup(UIRoot, "MemberHolder", false, false, true, true, 5, new Vector4(2, 2, 2, 2), new Color(0.12f, 0.12f, 0.12f)); UIFactory.SetLayoutElement(mainContentHolder, flexibleWidth: 9999, flexibleHeight: 9999); @@ -352,7 +349,7 @@ namespace UnityExplorer.UI.Inspectors // Member scroll pool - var memberBorder = UIFactory.CreateVerticalGroup(mainContentHolder, "ScrollPoolHolder", false, false, true, true, padding: new Vector4(2,2,2,2), + var memberBorder = UIFactory.CreateVerticalGroup(mainContentHolder, "ScrollPoolHolder", false, false, true, true, padding: new Vector4(2, 2, 2, 2), bgColor: new Color(0.05f, 0.05f, 0.05f)); UIFactory.SetLayoutElement(memberBorder, flexibleWidth: 9999, flexibleHeight: 9999); @@ -546,7 +543,7 @@ namespace UnityExplorer.UI.Inspectors textureButton.ButtonText.text = "Hide Texture"; } } - + // UI construction private void ConstructUnityObjectRow() diff --git a/src/UI/Models/InputFieldRef.cs b/src/UI/Models/InputFieldRef.cs index 0c61905..2564f22 100644 --- a/src/UI/Models/InputFieldRef.cs +++ b/src/UI/Models/InputFieldRef.cs @@ -29,8 +29,8 @@ namespace UnityExplorer.UI } } - public InputFieldRef(InputField component) - { + public InputFieldRef(InputField component) + { this.Component = component; Rect = component.GetComponent(); PlaceholderText = component.placeholder.TryCast(); diff --git a/src/UI/ObjectExplorer/ObjectSearch.cs b/src/UI/ObjectExplorer/ObjectSearch.cs index d5d4377..eec0d08 100644 --- a/src/UI/ObjectExplorer/ObjectSearch.cs +++ b/src/UI/ObjectExplorer/ObjectSearch.cs @@ -25,7 +25,7 @@ namespace UnityExplorer.UI.ObjectExplorer private ChildFilter m_childFilter = ChildFilter.Any; private string desiredTypeInput; private string lastCheckedTypeInput; - private bool lastTypeCanHaveGO; + private bool lastTypeCanHaveGO; public ButtonListHandler dataHandler; @@ -241,7 +241,7 @@ namespace UnityExplorer.UI.ObjectExplorer // RESULTS SCROLL POOL dataHandler = new ButtonListHandler(resultsScrollPool, GetEntries, SetCell, ShouldDisplayCell, OnCellClicked); - resultsScrollPool = UIFactory.CreateScrollPool(uiRoot, "ResultsList", out GameObject scrollObj, + resultsScrollPool = UIFactory.CreateScrollPool(uiRoot, "ResultsList", out GameObject scrollObj, out GameObject scrollContent); resultsScrollPool.Initialize(dataHandler); diff --git a/src/UI/ObjectExplorer/SceneExplorer.cs b/src/UI/ObjectExplorer/SceneExplorer.cs index e30ffc4..1f2e947 100644 --- a/src/UI/ObjectExplorer/SceneExplorer.cs +++ b/src/UI/ObjectExplorer/SceneExplorer.cs @@ -201,7 +201,7 @@ namespace UnityExplorer.UI.ObjectExplorer //Filter input field var inputField = UIFactory.CreateInputField(filterRow, "FilterInput", "Search..."); inputField.Component.targetGraphic.color = new Color(0.2f, 0.2f, 0.2f); - RuntimeProvider.Instance.SetColorBlock(inputField.Component, new Color(0.4f, 0.4f, 0.4f), new Color(0.2f, 0.2f, 0.2f), + RuntimeProvider.Instance.SetColorBlock(inputField.Component, new Color(0.4f, 0.4f, 0.4f), new Color(0.2f, 0.2f, 0.2f), new Color(0.08f, 0.08f, 0.08f)); UIFactory.SetLayoutElement(inputField.UIRoot, minHeight: 25); inputField.OnValueChanged += OnFilterInput; diff --git a/src/UI/ObjectExplorer/SceneHandler.cs b/src/UI/ObjectExplorer/SceneHandler.cs index 72cc07c..1b79a2b 100644 --- a/src/UI/ObjectExplorer/SceneHandler.cs +++ b/src/UI/ObjectExplorer/SceneHandler.cs @@ -13,7 +13,7 @@ namespace UnityExplorer.UI.ObjectExplorer /// /// The currently inspected Scene. /// - public static Scene? SelectedScene + public static Scene? SelectedScene { get => selectedScene; internal set @@ -93,7 +93,7 @@ namespace UnityExplorer.UI.ObjectExplorer Type sceneUtil = ReflectionUtility.GetTypeByName("UnityEngine.SceneManagement.SceneUtility"); if (sceneUtil == null) throw new Exception("This version of Unity does not ship with the 'SceneUtility' class, or it was not unstripped."); - + var method = sceneUtil.GetMethod("GetScenePathByBuildIndex", ReflectionUtility.FLAGS); int sceneCount = SceneManager.sceneCountInBuildSettings; for (int i = 0; i < sceneCount; i++) diff --git a/src/UI/ObjectExplorer/SearchProvider.cs b/src/UI/ObjectExplorer/SearchProvider.cs index 947a7a6..17e2ef3 100644 --- a/src/UI/ObjectExplorer/SearchProvider.cs +++ b/src/UI/ObjectExplorer/SearchProvider.cs @@ -35,7 +35,7 @@ namespace UnityExplorer.UI.ObjectExplorer public static class SearchProvider { - + private static bool Filter(Scene scene, SceneFilter filter) { switch (filter) @@ -53,7 +53,7 @@ namespace UnityExplorer.UI.ObjectExplorer } } - internal static List UnityObjectSearch(string input, string customTypeInput, SearchContext context, + internal static List UnityObjectSearch(string input, string customTypeInput, SearchContext context, ChildFilter childFilter, SceneFilter sceneFilter) { var results = new List(); diff --git a/src/UI/Panels/InspectorPanel.cs b/src/UI/Panels/InspectorPanel.cs index f2117d3..93a07a2 100644 --- a/src/UI/Panels/InspectorPanel.cs +++ b/src/UI/Panels/InspectorPanel.cs @@ -61,7 +61,7 @@ namespace UnityExplorer.UI.Panels { // add close all button to titlebar - var closeAllBtn = UIFactory.CreateButton(this.titleBar.transform.Find("CloseHolder").gameObject, "CloseAllBtn", "Close All", + var closeAllBtn = UIFactory.CreateButton(this.titleBar.transform.Find("CloseHolder").gameObject, "CloseAllBtn", "Close All", new Color(0.3f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(closeAllBtn.Component.gameObject, minHeight: 25, minWidth: 80); closeAllBtn.Component.transform.SetSiblingIndex(closeAllBtn.Component.transform.GetSiblingIndex() - 1); diff --git a/src/UI/Panels/PanelDragger.cs b/src/UI/Panels/PanelDragger.cs index 78524c5..192c5c4 100644 --- a/src/UI/Panels/PanelDragger.cs +++ b/src/UI/Panels/PanelDragger.cs @@ -1,17 +1,17 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; using UnityEngine; using UnityEngine.UI; using UnityExplorer.Core.Input; -using System.IO; -using System.Diagnostics; using UnityExplorer.UI.Models; -using System.Linq; using UnityExplorer.UI.Widgets.AutoComplete; namespace UnityExplorer.UI.Panels { - public class PanelDragger + public class PanelDragger { #region Static @@ -137,7 +137,7 @@ namespace UnityExplorer.UI.Panels Instances.Add(this); DragableArea = dragArea; Panel = panelToDrag; - + if (!canvasTransform) canvasTransform = Panel.GetComponentInParent().GetComponent(); diff --git a/src/UI/Panels/UIPanel.cs b/src/UI/Panels/UIPanel.cs index c425cb2..bcfe290 100644 --- a/src/UI/Panels/UIPanel.cs +++ b/src/UI/Panels/UIPanel.cs @@ -146,17 +146,17 @@ namespace UnityExplorer.UI.Panels if (Rect.rect.height < MinHeight) Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, MinHeight); } - + public static void EnsureValidPosition(RectTransform panel) { var pos = panel.localPosition; - + // Prevent panel going oustide screen bounds var halfW = Screen.width * 0.5f; var halfH = Screen.height * 0.5f; pos.x = Math.Max(-halfW, Math.Min(pos.x, halfW - panel.rect.width)); pos.y = Math.Max(-halfH + panel.rect.height, Math.Min(pos.y, halfH)); - + panel.localPosition = pos; } diff --git a/src/UI/UIFactory.cs b/src/UI/UIFactory.cs index bb8aa73..3a5f927 100644 --- a/src/UI/UIFactory.cs +++ b/src/UI/UIFactory.cs @@ -419,7 +419,7 @@ namespace UnityExplorer.UI toggle = toggleObj.AddComponent(); toggle.isOn = true; - + // second reference so we can use it inside the lambda, 'toggle' is an out var. Toggle toggleComp = toggle; toggle.onValueChanged.AddListener(Deselect); @@ -729,7 +729,7 @@ namespace UnityExplorer.UI var sliderContainer = CreateVerticalGroup(mainObj, "SliderContainer", false, false, true, true, 0, default, new Color(0.05f, 0.05f, 0.05f)); - SetLayoutElement(sliderContainer, minWidth: 25, flexibleWidth:0, flexibleHeight: 9999); + SetLayoutElement(sliderContainer, minWidth: 25, flexibleWidth: 0, flexibleHeight: 9999); sliderContainer.AddComponent(); CreateSliderScrollbar(sliderContainer, out Slider slider); @@ -837,7 +837,7 @@ namespace UnityExplorer.UI content.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize; // Slider - + GameObject scrollBarObj = CreateUIObject("AutoSliderScrollbar", mainObj); var scrollBarRect = scrollBarObj.GetComponent(); scrollBarRect.anchorMin = new Vector2(1, 0); @@ -846,22 +846,22 @@ namespace UnityExplorer.UI SetLayoutGroup(scrollBarObj, false, true, true, true); scrollBarObj.AddComponent().color = Color.white; scrollBarObj.AddComponent().showMaskGraphic = false; - + GameObject hiddenBar = CreateScrollbar(scrollBarObj, "HiddenScrollviewScroller", out var hiddenScrollbar); hiddenScrollbar.SetDirection(Scrollbar.Direction.BottomToTop, true); - + for (int i = 0; i < hiddenBar.transform.childCount; i++) { var child = hiddenBar.transform.GetChild(i); child.gameObject.SetActive(false); } - + CreateSliderScrollbar(scrollBarObj, out Slider scrollSlider); - + autoScrollbar = new AutoSliderScrollbar(hiddenScrollbar, scrollSlider, contentRect, viewportRect); - + // Set up the ScrollRect component - + var scrollRect = mainObj.AddComponent(); scrollRect.horizontal = false; scrollRect.vertical = true; @@ -870,10 +870,10 @@ namespace UnityExplorer.UI scrollRect.scrollSensitivity = 35; scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.Permanent; - + scrollRect.viewport = viewportRect; scrollRect.content = contentRect; - + return mainObj; } diff --git a/src/UI/UIManager.cs b/src/UI/UIManager.cs index ff804f9..4c8b943 100644 --- a/src/UI/UIManager.cs +++ b/src/UI/UIManager.cs @@ -352,7 +352,7 @@ namespace UnityExplorer.UI NavbarAnchor = ConfigManager.Main_Navbar_Anchor.Value; SetNavBarAnchor(); - ConfigManager.Main_Navbar_Anchor.OnValueChanged += (VerticalAnchor val) => + ConfigManager.Main_Navbar_Anchor.OnValueChanged += (VerticalAnchor val) => { NavbarAnchor = val; SetNavBarAnchor(); diff --git a/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs b/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs index e412aa1..0db5e97 100644 --- a/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs +++ b/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs @@ -169,7 +169,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete // Setting autocomplete cell buttons - private readonly Color selectedSuggestionColor = new Color(45/255f, 75/255f, 80/255f); + private readonly Color selectedSuggestionColor = new Color(45 / 255f, 75 / 255f, 80 / 255f); private readonly Color inactiveSuggestionColor = new Color(0.11f, 0.11f, 0.11f); private List GetEntries() => Suggestions; @@ -300,7 +300,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete { dataHandler = new ButtonListHandler(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked); - scrollPool = UIFactory.CreateScrollPool(this.content, "AutoCompleter", out GameObject scrollObj, + scrollPool = UIFactory.CreateScrollPool(this.content, "AutoCompleter", out GameObject scrollObj, out GameObject scrollContent); scrollPool.Initialize(dataHandler); UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999); @@ -308,7 +308,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete navigationTipRow = UIFactory.CreateHorizontalGroup(this.content, "BottomRow", true, true, true, true, 0, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(navigationTipRow, minHeight: 20, flexibleWidth: 9999); - UIFactory.CreateLabel(navigationTipRow, "HelpText", "Up/Down to select, Enter to use, Esc to close", + UIFactory.CreateLabel(navigationTipRow, "HelpText", "Up/Down to select, Enter to use, Esc to close", TextAnchor.MiddleLeft, Color.grey, false, 13); UIRoot.SetActive(false); diff --git a/src/UI/Widgets/AutoSliderScrollbar.cs b/src/UI/Widgets/AutoSliderScrollbar.cs index 5f4c12d..3505fbc 100644 --- a/src/UI/Widgets/AutoSliderScrollbar.cs +++ b/src/UI/Widgets/AutoSliderScrollbar.cs @@ -91,7 +91,7 @@ namespace UnityExplorer.UI.Widgets Slider.interactable = false; return; } - + var handleHeight = viewportHeight * Math.Min(1, viewportHeight / totalHeight); handleHeight = Math.Max(15f, handleHeight); diff --git a/src/UI/Widgets/ButtonList/ButtonListHandler.cs b/src/UI/Widgets/ButtonList/ButtonListHandler.cs index 17d3db5..4ab6eb0 100644 --- a/src/UI/Widgets/ButtonList/ButtonListHandler.cs +++ b/src/UI/Widgets/ButtonList/ButtonListHandler.cs @@ -26,7 +26,7 @@ namespace UnityExplorer.UI.Widgets } private string currentFilter; - public ButtonListHandler(ScrollPool scrollPool, Func> getEntriesMethod, + public ButtonListHandler(ScrollPool scrollPool, Func> getEntriesMethod, Action setICellMethod, Func shouldDisplayMethod, Action onCellClickedMethod) { diff --git a/src/UI/Widgets/InputFieldScroller.cs b/src/UI/Widgets/InputFieldScroller.cs index aeeb4f7..4fea90c 100644 --- a/src/UI/Widgets/InputFieldScroller.cs +++ b/src/UI/Widgets/InputFieldScroller.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; -using UnityEngine.UI; -using UnityEngine.EventSystems; using UnityEngine.Events; +using UnityEngine.EventSystems; +using UnityEngine.UI; using UnityExplorer.UI.Models; namespace UnityExplorer.UI.Widgets diff --git a/src/UI/Widgets/ScrollPool/DataHeightCache.cs b/src/UI/Widgets/ScrollPool/DataHeightCache.cs index 285b496..8f43a3b 100644 --- a/src/UI/Widgets/ScrollPool/DataHeightCache.cs +++ b/src/UI/Widgets/ScrollPool/DataHeightCache.cs @@ -118,7 +118,7 @@ namespace UnityExplorer.UI.Widgets if (!heightCache.Any()) return; - totalHeight -= heightCache[heightCache.Count - 1]; + totalHeight -= heightCache[heightCache.Count - 1]; heightCache.RemoveAt(heightCache.Count - 1); int idx = heightCache.Count; diff --git a/src/UI/Widgets/ScrollPool/ScrollPool.cs b/src/UI/Widgets/ScrollPool/ScrollPool.cs index 769e2ef..ec59588 100644 --- a/src/UI/Widgets/ScrollPool/ScrollPool.cs +++ b/src/UI/Widgets/ScrollPool/ScrollPool.cs @@ -11,7 +11,7 @@ using UnityExplorer.UI.Panels; namespace UnityExplorer.UI.Widgets { - public struct CellInfo + public struct CellInfo { public int cellIndex, dataIndex; } @@ -120,7 +120,7 @@ namespace UnityExplorer.UI.Widgets OnHeightChanged?.Invoke(); } } - + } #endregion @@ -129,7 +129,7 @@ namespace UnityExplorer.UI.Widgets public void Refresh(bool setCellData, bool jumpToTop = false) { if (jumpToTop) - { + { bottomDataIndex = CellPool.Count - 1; Content.anchoredPosition = Vector2.zero; } diff --git a/src/UI/Widgets/TransformTree/CachedTransform.cs b/src/UI/Widgets/TransformTree/CachedTransform.cs index d88189b..9218da3 100644 --- a/src/UI/Widgets/TransformTree/CachedTransform.cs +++ b/src/UI/Widgets/TransformTree/CachedTransform.cs @@ -33,10 +33,10 @@ namespace UnityExplorer.UI.Widgets { bool ret = false; - if (Value != transform - || depth != Depth - || ChildCount != transform.childCount - || Name != transform.name + if (Value != transform + || depth != Depth + || ChildCount != transform.childCount + || Name != transform.name || Enabled != transform.gameObject.activeSelf) { Value = transform;