Misc cleanups and adjustments

This commit is contained in:
Sinai 2021-05-16 21:46:38 +10:00
parent ca65affb5c
commit fb6e413153
16 changed files with 68 additions and 55 deletions

View File

@ -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];

View File

@ -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<Il2CppSystem.Object>(5);
list.Add("one");
list.Add("two");
AAAAAAACppList = list.TryCast<Il2CppSystem.Collections.IList>();
CppBoxedDict = new Dictionary<Il2CppSystem.String, Il2CppSystem.Object>();
CppBoxedDict.Add("1", new Il2CppSystem.Int32 { m_value = 1 }.BoxIl2CppObject());
CppBoxedDict.Add("2", new Il2CppSystem.Int32 { m_value = 2 }.BoxIl2CppObject());

View File

@ -82,6 +82,7 @@ namespace UnityExplorer
Log($"{NAME} {VERSION} initialized.");
//InspectorManager.Inspect(typeof(TestClass));
InspectorManager.Inspect(Camera.main.gameObject);
}
/// <summary>

View File

@ -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()

View File

@ -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)
{

View File

@ -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);

View File

@ -8,8 +8,24 @@ using UnityExplorer.UI.Models;
namespace UnityExplorer.UI
{
public class InputFieldRef : UIBehaviourModel
public class InputFieldRef : UIModel
{
public static readonly HashSet<InputFieldRef> inputsPendingUpdate = new HashSet<InputFieldRef>();
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;

View File

@ -30,7 +30,7 @@ namespace UnityExplorer.UI.ObjectExplorer
private string lastCheckedTypeInput;
private bool lastTypeCanHaveGO;
public ButtonListSource<object> dataHandler;
public ButtonListHandler<object, ButtonCell> dataHandler;
private ScrollPool<ButtonCell> resultsScrollPool;
private List<object> currentResults = new List<object>();
@ -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<object>(resultsScrollPool, GetEntries, SetCell, ShouldDisplayCell, OnCellClicked);
resultsScrollPool = UIFactory.CreateScrollPool<ButtonCell>(uiRoot, "ResultsList", out GameObject scrollObj, out GameObject scrollContent);
//if (!Pool<ButtonCell>.PrototypeObject)
// Pool<ButtonCell>.PrototypeObject = ButtonCell.CreatePrototypeCell(Pool<ButtonCell>.InactiveHolder).gameObject;
dataHandler = new ButtonListHandler<object, ButtonCell>(resultsScrollPool, GetEntries, SetCell, ShouldDisplayCell, OnCellClicked);
resultsScrollPool = UIFactory.CreateScrollPool<ButtonCell>(uiRoot, "ResultsList", out GameObject scrollObj,
out GameObject scrollContent);
resultsScrollPool.Initialize(dataHandler);
UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999);

View File

@ -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<Mask>().enabled = false;

View File

@ -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; }

View File

@ -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<Mask>().enabled = false;
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.content, true, true, true, true, 4, padLeft: 5, padRight: 5);

View File

@ -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;

View File

@ -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<HorizontalLayoutGroup>(closeHolder, false, false, true, true, 0, childAlignment: TextAnchor.MiddleRight);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(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));

View File

@ -460,11 +460,10 @@ namespace UnityExplorer.UI
public static InputFieldRef CreateInputField(GameObject parent, string name, string placeHolderText)
{
GameObject mainObj = CreateUIObject(name, parent);
//SetLayoutGroup<VerticalLayoutGroup>(mainObj, true, true, true, true);
Image mainImage = mainObj.AddComponent<Image>();
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<InputField>();
Navigation nav = inputField.navigation;
@ -480,7 +479,6 @@ namespace UnityExplorer.UI
GameObject textArea = CreateUIObject("TextArea", mainObj);
textArea.AddComponent<RectMask2D>();
//textArea.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
RectTransform textAreaRect = textArea.GetComponent<RectTransform>();
textAreaRect.anchorMin = Vector2.zero;
@ -488,8 +486,6 @@ namespace UnityExplorer.UI
textAreaRect.offsetMin = Vector2.zero;
textAreaRect.offsetMax = Vector2.zero;
// mainInput.textViewport = textArea.GetComponent<RectTransform>();
GameObject placeHolderObj = CreateUIObject("Placeholder", textArea);
Text placeholderText = placeHolderObj.AddComponent<Text>();
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);

View File

@ -31,7 +31,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
public static ISuggestionProvider CurrentHandler { get; private set; }
public static ButtonListSource<Suggestion> dataHandler;
public static ButtonListHandler<Suggestion, ButtonCell> dataHandler;
public static ScrollPool<ButtonCell> scrollPool;
private static GameObject navigationTipRow;
@ -299,9 +299,10 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
public override void ConstructPanelContent()
{
dataHandler = new ButtonListSource<Suggestion>(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked);
dataHandler = new ButtonListHandler<Suggestion, ButtonCell>(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked);
scrollPool = UIFactory.CreateScrollPool<ButtonCell>(this.content, "AutoCompleter", out GameObject scrollObj, out GameObject scrollContent);
scrollPool = UIFactory.CreateScrollPool<ButtonCell>(this.content, "AutoCompleter", out GameObject scrollObj,
out GameObject scrollContent);
scrollPool.Initialize(dataHandler);
UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999);
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(scrollContent, true, false, true, false);

View File

@ -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<RectTransform>();
Rect.anchorMin = new Vector2(0, 1);