diff --git a/src/Core/Reflection/Il2CppReflection.cs b/src/Core/Reflection/Il2CppReflection.cs index 350ffa4..2289e24 100644 --- a/src/Core/Reflection/Il2CppReflection.cs +++ b/src/Core/Reflection/Il2CppReflection.cs @@ -745,7 +745,7 @@ namespace UnityExplorer //// var valueType = value.GetActualType(); //// //// Type typeOfKeys, typeOfValues; - //// if (valueType.IsGenericType && valueType.GetGenericArguments() is var args && args.Length == 2) + //// if (valueType.IsGenericType && valueType.GetGenericArguments() is ParameterInfo[] args && args.Length == 2) //// { //// typeOfKeys = args[0]; //// typeOfValues = args[1]; diff --git a/src/Core/Tests/TestClass.cs b/src/Core/Tests/TestClass.cs index 521738e..f36807e 100644 --- a/src/Core/Tests/TestClass.cs +++ b/src/Core/Tests/TestClass.cs @@ -194,6 +194,8 @@ namespace UnityExplorer.Tests #if CPP + public static Il2CppSystem.Collections.IList AAAAAAACppList; + public static string testStringOne = "Test"; public static Il2CppSystem.Object testStringTwo = "string boxed as cpp object"; public static Il2CppSystem.String testStringThree = "string boxed as cpp string"; @@ -237,6 +239,11 @@ namespace UnityExplorer.Tests BigList.Add(i.ToString()); #if CPP + var list = new Il2CppSystem.Collections.Generic.List(5); + list.Add("one"); + list.Add("two"); + AAAAAAACppList = list.TryCast(); + CppBoxedDict = new Dictionary(); CppBoxedDict.Add("1", new Il2CppSystem.Int32 { m_value = 1 }.BoxIl2CppObject()); CppBoxedDict.Add("2", new Il2CppSystem.Int32 { m_value = 2 }.BoxIl2CppObject()); diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 2e0a52f..17e3dbd 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -82,6 +82,7 @@ namespace UnityExplorer Log($"{NAME} {VERSION} initialized."); //InspectorManager.Inspect(typeof(TestClass)); + InspectorManager.Inspect(Camera.main.gameObject); } /// diff --git a/src/UI/CSConsole/ConsoleController.cs b/src/UI/CSConsole/ConsoleController.cs index 170a7f3..a3fe7ca 100644 --- a/src/UI/CSConsole/ConsoleController.cs +++ b/src/UI/CSConsole/ConsoleController.cs @@ -321,6 +321,7 @@ namespace UnityExplorer.UI.CSConsole private static void SetCaretPosition(int caretPosition) { settingCaretCoroutine = true; + Input.Component.readOnly = true; RuntimeProvider.Instance.StartCoroutine(SetAutocompleteCaretCoro(caretPosition)); } @@ -343,6 +344,7 @@ namespace UnityExplorer.UI.CSConsole color.a = defaultInputFieldAlpha; Input.Component.selectionColor = color; + Input.Component.readOnly = false; settingCaretCoroutine = false; } @@ -575,7 +577,7 @@ public class HelloWorld internal const string HELP_COROUTINES = @"// To start a Coroutine directly, use ""Start(SomeCoroutine());"" in REPL mode. -// To define a coroutine, you will need to compile it seperately. For example: +// To declare a coroutine, you will need to compile it separately. For example: public class MyCoro { public static IEnumerator Main() diff --git a/src/UI/CacheObject/Views/CacheListEntryCell.cs b/src/UI/CacheObject/Views/CacheListEntryCell.cs index 46d7a9b..16341fe 100644 --- a/src/UI/CacheObject/Views/CacheListEntryCell.cs +++ b/src/UI/CacheObject/Views/CacheListEntryCell.cs @@ -13,8 +13,8 @@ namespace UnityExplorer.UI.CacheObject.Views public Image Image { get; private set; } public InteractiveList ListOwner => Occupant.Owner as InteractiveList; - public static Color EvenColor = new Color(0.07f, 0.07f, 0.07f); - public static Color OddColor = new Color(0.063f, 0.063f, 0.063f); + public static Color EvenColor = new Color(0.12f, 0.12f, 0.12f); + public static Color OddColor = new Color(0.1f, 0.1f, 0.1f); public override GameObject CreateContent(GameObject parent) { diff --git a/src/UI/IValues/InteractiveValueStruct.cs b/src/UI/IValues/InteractiveValueStruct.cs index 6d37b12..adbc56f 100644 --- a/src/UI/IValues/InteractiveValueStruct.cs +++ b/src/UI/IValues/InteractiveValueStruct.cs @@ -180,8 +180,8 @@ namespace UnityExplorer.UI.IValues fieldRows.Add(row); - var label = UIFactory.CreateLabel(row, "Label", "notset", TextAnchor.MiddleRight); - UIFactory.SetLayoutElement(label.gameObject, minHeight: 25, minWidth: 175, flexibleWidth: 0); + var label = UIFactory.CreateLabel(row, "Label", "notset", TextAnchor.MiddleLeft); + UIFactory.SetLayoutElement(label.gameObject, minHeight: 25, minWidth: 50, flexibleWidth: 0); label.horizontalOverflow = HorizontalWrapMode.Wrap; labels.Add(label); diff --git a/src/UI/Models/InputFieldRef.cs b/src/UI/Models/InputFieldRef.cs index 0ddba3d..fca7f37 100644 --- a/src/UI/Models/InputFieldRef.cs +++ b/src/UI/Models/InputFieldRef.cs @@ -8,8 +8,24 @@ using UnityExplorer.UI.Models; namespace UnityExplorer.UI { - public class InputFieldRef : UIBehaviourModel + public class InputFieldRef : UIModel { + public static readonly HashSet inputsPendingUpdate = new HashSet(); + + public static void UpdateInstances() + { + if (inputsPendingUpdate.Any()) + { + foreach (var entry in inputsPendingUpdate) + { + LayoutRebuilder.MarkLayoutForRebuild(entry.Rect); + entry.OnValueChanged?.Invoke(entry.Component.text); + } + + inputsPendingUpdate.Clear(); + } + } + public InputFieldRef(InputField component) { this.Component = component; @@ -33,22 +49,11 @@ namespace UnityExplorer.UI public TextGenerator TextGenerator => Component.cachedInputTextGenerator; public bool ReachedMaxVerts => TextGenerator.vertexCount >= UIManager.MAX_TEXT_VERTS; - private bool updatedWanted; private void OnInputChanged(string value) { - updatedWanted = true; - } - - public override void Update() - { - if (updatedWanted) - { - LayoutRebuilder.MarkLayoutForRebuild(Rect); - - OnValueChanged?.Invoke(Component.text); - updatedWanted = false; - } + if (!inputsPendingUpdate.Contains(this)) + inputsPendingUpdate.Add(this); } public override GameObject UIRoot => Component.gameObject; diff --git a/src/UI/ObjectExplorer/ObjectSearch.cs b/src/UI/ObjectExplorer/ObjectSearch.cs index 6e8531c..e09145b 100644 --- a/src/UI/ObjectExplorer/ObjectSearch.cs +++ b/src/UI/ObjectExplorer/ObjectSearch.cs @@ -30,7 +30,7 @@ namespace UnityExplorer.UI.ObjectExplorer private string lastCheckedTypeInput; private bool lastTypeCanHaveGO; - public ButtonListSource dataHandler; + public ButtonListHandler dataHandler; private ScrollPool resultsScrollPool; private List currentResults = new List(); @@ -74,7 +74,7 @@ namespace UnityExplorer.UI.ObjectExplorer public void Update() { - if (lastCheckedTypeInput != desiredTypeInput) + if (m_context == SearchContext.UnityObject && lastCheckedTypeInput != desiredTypeInput) { lastCheckedTypeInput = desiredTypeInput; @@ -101,10 +101,9 @@ namespace UnityExplorer.UI.ObjectExplorer { m_context = (SearchContext)value; - bool shouldShowGoFilters = m_context == SearchContext.UnityObject; - - sceneFilterRow.SetActive(shouldShowGoFilters); - childFilterRow.SetActive(shouldShowGoFilters); + lastCheckedTypeInput = null; + sceneFilterRow.SetActive(false); + childFilterRow.SetActive(false); unityObjectClassRow.SetActive(m_context == SearchContext.UnityObject); } @@ -244,11 +243,9 @@ namespace UnityExplorer.UI.ObjectExplorer // RESULTS SCROLL POOL - dataHandler = new ButtonListSource(resultsScrollPool, GetEntries, SetCell, ShouldDisplayCell, OnCellClicked); - resultsScrollPool = UIFactory.CreateScrollPool(uiRoot, "ResultsList", out GameObject scrollObj, out GameObject scrollContent); - - //if (!Pool.PrototypeObject) - // Pool.PrototypeObject = ButtonCell.CreatePrototypeCell(Pool.InactiveHolder).gameObject; + dataHandler = new ButtonListHandler(resultsScrollPool, GetEntries, SetCell, ShouldDisplayCell, OnCellClicked); + resultsScrollPool = UIFactory.CreateScrollPool(uiRoot, "ResultsList", out GameObject scrollObj, + out GameObject scrollContent); resultsScrollPool.Initialize(dataHandler); UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999); diff --git a/src/UI/ObjectExplorer/SceneExplorer.cs b/src/UI/ObjectExplorer/SceneExplorer.cs index b35a1c7..ea94762 100644 --- a/src/UI/ObjectExplorer/SceneExplorer.cs +++ b/src/UI/ObjectExplorer/SceneExplorer.cs @@ -120,6 +120,11 @@ namespace UnityExplorer.UI.ObjectExplorer private void OnFilterInput(string input) { + if ((!string.IsNullOrEmpty(input) && !Tree.Filtering) || (string.IsNullOrEmpty(input) && Tree.Filtering)) + { + Tree.displayedObjects.Clear(); + } + Tree.CurrentFilter = input; Tree.RefreshData(true, true); } @@ -208,7 +213,7 @@ namespace UnityExplorer.UI.ObjectExplorer UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999); UIFactory.SetLayoutElement(scrollContent, flexibleHeight: 9999); - Tree = new TransformTree(scrollPool) { GetRootEntriesMethod = GetRootEntries }; + Tree = new TransformTree(scrollPool, GetRootEntries); Tree.Init(); Tree.RefreshData(true, true); //scrollPool.Viewport.GetComponent().enabled = false; diff --git a/src/UI/Panels/CSConsolePanel.cs b/src/UI/Panels/CSConsolePanel.cs index bbadc66..1a4bdc3 100644 --- a/src/UI/Panels/CSConsolePanel.cs +++ b/src/UI/Panels/CSConsolePanel.cs @@ -15,7 +15,7 @@ namespace UnityExplorer.UI.Panels { public override string Name => "C# Console"; public override UIManager.Panels PanelType => UIManager.Panels.CSConsole; - public override int MinWidth => 740; + public override int MinWidth => 750; public override int MinHeight => 300; public InputFieldScroller InputScroll { get; private set; } diff --git a/src/UI/Panels/InspectorPanel.cs b/src/UI/Panels/InspectorPanel.cs index e51627f..5d1db78 100644 --- a/src/UI/Panels/InspectorPanel.cs +++ b/src/UI/Panels/InspectorPanel.cs @@ -44,13 +44,6 @@ namespace UnityExplorer.UI.Panels public override string GetSaveDataFromConfigManager() => ConfigManager.InspectorData.Value; - //public override void LoadSaveData() - //{ - // ApplySaveData(ConfigManager.InspectorData.Value); - // - // InspectorManager.PanelWidth = this.mainPanelRect.rect.width; - //} - public override void DoSaveToConfigElement() { ConfigManager.InspectorData.Value = this.ToSaveData(); @@ -66,6 +59,14 @@ namespace UnityExplorer.UI.Panels public override void ConstructPanelContent() { + // add close all button to titlebar + + 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); + closeAllBtn.OnClick += InspectorManager.CloseAllTabs; + // this.UIRoot.GetComponent().enabled = false; UIFactory.SetLayoutGroup(this.content, true, true, true, true, 4, padLeft: 5, padRight: 5); diff --git a/src/UI/Panels/LogPanel.cs b/src/UI/Panels/LogPanel.cs index 1e30027..43a5db6 100644 --- a/src/UI/Panels/LogPanel.cs +++ b/src/UI/Panels/LogPanel.cs @@ -29,7 +29,7 @@ namespace UnityExplorer.UI.Panels public override string Name => "Log"; public override UIManager.Panels PanelType => UIManager.Panels.ConsoleLog; - public override int MinWidth => 300; + public override int MinWidth => 350; public override int MinHeight => 75; public override bool ShouldSaveActiveState => true; public override bool ShowByDefault => true; diff --git a/src/UI/Panels/UIPanel.cs b/src/UI/Panels/UIPanel.cs index 484c73c..68aa2cf 100644 --- a/src/UI/Panels/UIPanel.cs +++ b/src/UI/Panels/UIPanel.cs @@ -188,13 +188,13 @@ namespace UnityExplorer.UI.Panels // Title text var titleTxt = UIFactory.CreateLabel(titleBar, "TitleBar", Name, TextAnchor.MiddleLeft); - UIFactory.SetLayoutElement(titleTxt.gameObject, minWidth: 250, minHeight: 25, flexibleHeight: 0, flexibleWidth: 0); + UIFactory.SetLayoutElement(titleTxt.gameObject, minWidth: 250, minHeight: 25, flexibleHeight: 0); // close button var closeHolder = UIFactory.CreateUIObject("CloseHolder", titleBar); UIFactory.SetLayoutElement(closeHolder, minHeight: 25, flexibleHeight: 0, minWidth: 30, flexibleWidth: 9999); - UIFactory.SetLayoutGroup(closeHolder, false, false, true, true, 0, childAlignment: TextAnchor.MiddleRight); + UIFactory.SetLayoutGroup(closeHolder, false, false, true, true, 3, childAlignment: TextAnchor.MiddleRight); var closeBtn = UIFactory.CreateButton(closeHolder, "CloseButton", "—"); UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0); RuntimeProvider.Instance.SetColorBlock(closeBtn.Component, new Color(0.33f, 0.32f, 0.31f)); diff --git a/src/UI/UIFactory.cs b/src/UI/UIFactory.cs index 9f00b2f..371ef63 100644 --- a/src/UI/UIFactory.cs +++ b/src/UI/UIFactory.cs @@ -460,11 +460,10 @@ namespace UnityExplorer.UI public static InputFieldRef CreateInputField(GameObject parent, string name, string placeHolderText) { GameObject mainObj = CreateUIObject(name, parent); - //SetLayoutGroup(mainObj, true, true, true, true); Image mainImage = mainObj.AddComponent(); mainImage.type = Image.Type.Sliced; - mainImage.color = new Color(0.04f, 0.04f, 0.04f, 0.75f); + mainImage.color = new Color(0, 0, 0, 0.5f); var inputField = mainObj.AddComponent(); Navigation nav = inputField.navigation; @@ -480,7 +479,6 @@ namespace UnityExplorer.UI GameObject textArea = CreateUIObject("TextArea", mainObj); textArea.AddComponent(); - //textArea.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize; RectTransform textAreaRect = textArea.GetComponent(); textAreaRect.anchorMin = Vector2.zero; @@ -488,8 +486,6 @@ namespace UnityExplorer.UI textAreaRect.offsetMin = Vector2.zero; textAreaRect.offsetMax = Vector2.zero; - // mainInput.textViewport = textArea.GetComponent(); - GameObject placeHolderObj = CreateUIObject("Placeholder", textArea); Text placeholderText = placeHolderObj.AddComponent(); SetDefaultTextValues(placeholderText); @@ -505,8 +501,6 @@ namespace UnityExplorer.UI placeHolderRect.offsetMin = Vector2.zero; placeHolderRect.offsetMax = Vector2.zero; - //SetLayoutElement(placeHolderObj, minWidth: 20, flexibleWidth: 5000); - inputField.placeholder = placeholderText; GameObject inputTextObj = CreateUIObject("Text", textArea); diff --git a/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs b/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs index 4e59e90..122dcb6 100644 --- a/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs +++ b/src/UI/Widgets/AutoComplete/AutoCompleteModal.cs @@ -31,7 +31,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete public static ISuggestionProvider CurrentHandler { get; private set; } - public static ButtonListSource dataHandler; + public static ButtonListHandler dataHandler; public static ScrollPool scrollPool; private static GameObject navigationTipRow; @@ -299,9 +299,10 @@ namespace UnityExplorer.UI.Widgets.AutoComplete public override void ConstructPanelContent() { - dataHandler = new ButtonListSource(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked); + dataHandler = new ButtonListHandler(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked); - scrollPool = UIFactory.CreateScrollPool(this.content, "AutoCompleter", out GameObject scrollObj, out GameObject scrollContent); + scrollPool = UIFactory.CreateScrollPool(this.content, "AutoCompleter", out GameObject scrollObj, + out GameObject scrollContent); scrollPool.Initialize(dataHandler); UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999); UIFactory.SetLayoutGroup(scrollContent, true, false, true, false); diff --git a/src/UI/Widgets/ButtonList/ButtonCell.cs b/src/UI/Widgets/ButtonList/ButtonCell.cs index e1299ef..976277f 100644 --- a/src/UI/Widgets/ButtonList/ButtonCell.cs +++ b/src/UI/Widgets/ButtonList/ButtonCell.cs @@ -39,9 +39,9 @@ namespace UnityExplorer.UI.Widgets #endregion - public GameObject CreateContent(GameObject parent) + public virtual GameObject CreateContent(GameObject parent) { - UIRoot = UIFactory.CreateHorizontalGroup(parent, "ButtonCell", true, true, true, true, 2, default, + UIRoot = UIFactory.CreateHorizontalGroup(parent, "ButtonCell", true, false, true, true, 2, default, new Color(0.11f, 0.11f, 0.11f), TextAnchor.MiddleCenter); Rect = UIRoot.GetComponent(); Rect.anchorMin = new Vector2(0, 1);