Some UI adjustments and layout fixes

This commit is contained in:
Sinai
2021-05-17 18:47:37 +10:00
parent fb6e413153
commit 2fc9657560
7 changed files with 108 additions and 63 deletions

View File

@ -18,6 +18,8 @@ namespace UnityExplorer.UI.Inspectors
{
public GameObject GOTarget => Target as GameObject;
public GameObject Content;
public GameObjectControls GOControls;
public TransformTree TransformTree;
@ -217,11 +219,17 @@ namespace UnityExplorer.UI.Inspectors
public override GameObject CreateContent(GameObject parent)
{
UIRoot = UIFactory.CreateVerticalGroup(Pool<GameObjectInspector>.Instance.InactiveHolder,
"GameObjectInspector", true, true, true, true, 5, new Vector4(4, 4, 4, 4), new Color(0.065f, 0.065f, 0.065f));
"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,
new Color(0.065f, 0.065f, 0.065f));
UIFactory.SetLayoutElement(scrollObj, minHeight: 300, flexibleWidth: 9999, flexibleHeight: 1);
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(Content, spacing: 3, padTop: 2, padBottom: 2, padLeft: 2, padRight: 2);
// Construct GO Controls
GOControls = new GameObjectControls(this);
ConstructLists();
return UIRoot;
@ -231,9 +239,12 @@ namespace UnityExplorer.UI.Inspectors
private void ConstructLists()
{
var listHolder = UIFactory.CreateUIObject("ListTitles", UIRoot);
var listHolder = UIFactory.CreateUIObject("ListHolders", UIRoot);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(listHolder, false, true, true, true, 8, 2, 2, 2, 2);
UIFactory.SetLayoutElement(listHolder, flexibleWidth: 9999, flexibleHeight: 9999);
UIFactory.SetLayoutElement(listHolder, minHeight: 350, flexibleWidth: 9999, flexibleHeight: 9999);
//var listRect = listHolder.GetComponent<RectTransform>();
//listRect.anchorMin = new Vector2(0, 1);
//listRect.anchorMax = new Vector2(1, 1);
// Left group (Children)
@ -268,7 +279,7 @@ namespace UnityExplorer.UI.Inspectors
// Right group (Components)
var rightGroup = UIFactory.CreateUIObject("ChildrenGroup", listHolder);
var rightGroup = UIFactory.CreateUIObject("ComponentGroup", listHolder);
UIFactory.SetLayoutElement(rightGroup, flexibleWidth: 9999, flexibleHeight: 9999);
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(rightGroup, false, false, true, true, 2);

View File

@ -99,11 +99,14 @@ namespace UnityExplorer.UI.Inspectors
{
cell.BehaviourToggle.interactable = true;
cell.BehaviourToggle.Set(comp.TryCast<Behaviour>().enabled, false);
cell.BehaviourToggle.graphic.color = new Color(0.8f, 1, 0.8f, 0.3f);
}
else
{
cell.BehaviourToggle.interactable = false;
cell.BehaviourToggle.Set(false, false);
cell.BehaviourToggle.Set(true, false);
//RuntimeProvider.Instance.SetColorBlock(cell.BehaviourToggle,)
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.

View File

@ -196,6 +196,8 @@ namespace UnityExplorer.UI.Inspectors
private void DoSetParent(Transform transform)
{
ExplorerCore.Log($"Setting target's transform parent to: {(transform == null ? "null" : $"'{transform.name}'")}");
if (GOTarget.GetComponent<RectTransform>())
GOTarget.transform.SetParent(transform, false);
else
@ -434,9 +436,10 @@ namespace UnityExplorer.UI.Inspectors
private void ConstructTopInfo()
{
var topInfoHolder = UIFactory.CreateVerticalGroup(Parent.UIRoot, "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: 25, flexibleWidth: 9999);
UIFactory.SetLayoutElement(topInfoHolder, minHeight: 100, flexibleWidth: 9999);
topInfoHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
// first row (parent, path)
@ -449,11 +452,16 @@ namespace UnityExplorer.UI.Inspectors
UIFactory.SetLayoutElement(ViewParentButton.Component.gameObject, minHeight: 25, minWidth: 100);
ViewParentButton.OnClick += OnViewParentClicked;
this.PathInput = UIFactory.CreateInputField(firstRow, "PathInput", "Enter a GameObject name or path...");
this.PathInput = UIFactory.CreateInputField(firstRow, "PathInput", "...");
PathInput.Component.textComponent.color = Color.grey;
PathInput.Component.textComponent.fontSize = 14;
UIFactory.SetLayoutElement(PathInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 9999);
PathInput.Component.lineType = InputField.LineType.MultiLineSubmit;
//var pathApplyBtn = UIFactory.CreateButton(firstRow, "PathButton", "Set Parent Path", new Color(0.2f, 0.2f, 0.2f));
//UIFactory.SetLayoutElement(pathApplyBtn.Component.gameObject, minHeight: 25, minWidth: 120);
//pathApplyBtn.OnClick += () => { OnPathEndEdit(PathInput.Text); };
PathInput.Component.onEndEdit.AddListener((string val) => { OnPathEndEdit(val); });
// Title and update row
@ -597,11 +605,14 @@ namespace UnityExplorer.UI.Inspectors
private void ConstructTransformControls()
{
//var transformGroup = UIFactory.CreateUIObject("TransformGroup", UIRoot);
//UIFactory.SetLayoutGroup<VerticalLayoutGroup>(transformGroup, false, false, true, true, 2, 2, 2);
var transformGroup = UIFactory.CreateVerticalGroup(Parent.UIRoot, "TransformControls", false, false, true, true, 2,
var transformGroup = UIFactory.CreateVerticalGroup(Parent.Content, "TransformControls", false, false, true, true, 2,
new Vector4(2, 2, 0, 0), new Color(0.1f, 0.1f, 0.1f));
UIFactory.SetLayoutElement(transformGroup, minHeight: 25, flexibleWidth: 9999);
UIFactory.SetLayoutElement(transformGroup, minHeight: 100, flexibleWidth: 9999);
//transformGroup.SetActive(false);
//var groupRect = transformGroup.GetComponent<RectTransform>();
//groupRect.anchorMin = new Vector2(0, 1);
//groupRect.anchorMax = new Vector2(1, 1);
//groupRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 100);
PositionControl = AddTransformRow(transformGroup, "Position:", TransformType.Position);
LocalPositionControl = AddTransformRow(transformGroup, "Local Position:", TransformType.LocalPosition);