diff --git a/src/UI/Main/InspectorManager.cs b/src/UI/Main/InspectorManager.cs index 4e0a1ea..162b87d 100644 --- a/src/UI/Main/InspectorManager.cs +++ b/src/UI/Main/InspectorManager.cs @@ -29,9 +29,12 @@ namespace ExplorerBeta.UI.Main public void Update() { - foreach (InspectorBase tab in m_currentInspectors) + for (int i = 0; i < m_currentInspectors.Count; i++) { - tab.Update(); + if (i >= m_currentInspectors.Count) + break; + + m_currentInspectors[i].Update(); } } diff --git a/src/UI/Main/Inspectors/GameObjectInspector.cs b/src/UI/Main/Inspectors/GameObjectInspector.cs index 4ab6a10..45fd036 100644 --- a/src/UI/Main/Inspectors/GameObjectInspector.cs +++ b/src/UI/Main/Inspectors/GameObjectInspector.cs @@ -1,10 +1,18 @@ using System; using System.Collections.Generic; +using ExplorerBeta.Helpers; +using TMPro; using UnityEngine; using UnityEngine.UI; namespace ExplorerBeta.UI.Main.Inspectors { + // TODO: + // make page handler for children and component lists + // -- clicking a child.. open new tab or change this tab target? + // make top info panel (path, scene, layer, enabled) + // make controls panel (transform controls, set parent, etc) + public class GameObjectInspector : InspectorBase { public override string TabLabel => $" [G] {TargetGO?.name}"; @@ -12,6 +20,10 @@ namespace ExplorerBeta.UI.Main.Inspectors // just to help with casting in il2cpp public GameObject TargetGO; + // cached ui elements + public TMP_InputField m_nameInput; + public TMP_InputField m_pathInput; + public GameObjectInspector(GameObject target) : base(target) { TargetGO = target; @@ -34,7 +46,18 @@ namespace ExplorerBeta.UI.Main.Inspectors return; } - // TODO refresh children and components + m_nameInput.text = TargetGO.name; + m_pathInput.text = TargetGO.transform.GetTransformPath(); + } + + private void ChangeInspectorTarget(GameObject newTarget) + { + if (!newTarget) + return; + + this.Target = this.TargetGO = newTarget; + + // ? } #region UI CONSTRUCTION @@ -45,34 +68,198 @@ namespace ExplorerBeta.UI.Main.Inspectors this.Content = UIFactory.CreateScrollView(parent, out GameObject scrollContent, new Color(0.1f, 0.1f, 0.1f, 1)); - var nameObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft); - var nameText = nameObj.GetComponent(); - nameText.text = TargetGO.name; - nameText.fontSize = 18; + var scrollLayout = scrollContent.GetComponent(); + scrollLayout.childForceExpandHeight = false; + scrollLayout.childControlHeight = true; + scrollLayout.spacing = 5; - var childListObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft); - var childListText = childListObj.GetComponent(); - childListText.text = "Children:"; + ConstructTopArea(scrollContent); - foreach (Transform child in TargetGO.transform) + ConstructChildList(scrollContent); + + ConstructCompList(scrollContent); + + ConstructControls(scrollContent); + } + + private void ConstructTopArea(GameObject scrollContent) + { + // name row + + var nameObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f)); + var nameGroup = nameObj.GetComponent(); + nameGroup.childForceExpandHeight = false; + nameGroup.childForceExpandWidth = false; + nameGroup.childControlHeight = false; + nameGroup.childControlWidth = true; + var nameRect = nameObj.GetComponent(); + nameRect.sizeDelta = new Vector2(nameRect.sizeDelta.x, 25); + var nameLayout = nameObj.AddComponent(); + nameLayout.minHeight = 25; + nameLayout.flexibleHeight = 0; + + var nameTextObj = UIFactory.CreateTMPLabel(nameObj, TextAlignmentOptions.Left); + var nameTextText = nameTextObj.GetComponent(); + nameTextText.text = "Name:"; + nameTextText.fontSize = 14; + var nameTextLayout = nameTextObj.AddComponent(); + nameTextLayout.minHeight = 25; + nameTextLayout.flexibleHeight = 0; + nameTextLayout.minWidth = 60; + nameTextLayout.flexibleWidth = 0; + + var nameInputObj = UIFactory.CreateTMPInput(nameObj, 14, 0, (int)TextAlignmentOptions.MidlineLeft); + var nameInputRect = nameInputObj.GetComponent(); + nameInputRect.sizeDelta = new Vector2(nameInputRect.sizeDelta.x, 25); + m_nameInput = nameInputObj.GetComponent(); + m_nameInput.text = TargetGO.name; + m_nameInput.lineType = TMP_InputField.LineType.SingleLine; + + var applyNameBtnObj = UIFactory.CreateButton(nameObj); + var applyNameBtn = applyNameBtnObj.GetComponent