mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +08:00
GameObject inspector taking shape
This commit is contained in:
parent
b5b3e90b09
commit
b9b5d721c8
@ -29,9 +29,12 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
public void Update()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ExplorerBeta.Helpers;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace ExplorerBeta.UI.Main.Inspectors
|
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 class GameObjectInspector : InspectorBase
|
||||||
{
|
{
|
||||||
public override string TabLabel => $" [G] {TargetGO?.name}";
|
public override string TabLabel => $" [G] {TargetGO?.name}";
|
||||||
@ -12,6 +20,10 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
|||||||
// just to help with casting in il2cpp
|
// just to help with casting in il2cpp
|
||||||
public GameObject TargetGO;
|
public GameObject TargetGO;
|
||||||
|
|
||||||
|
// cached ui elements
|
||||||
|
public TMP_InputField m_nameInput;
|
||||||
|
public TMP_InputField m_pathInput;
|
||||||
|
|
||||||
public GameObjectInspector(GameObject target) : base(target)
|
public GameObjectInspector(GameObject target) : base(target)
|
||||||
{
|
{
|
||||||
TargetGO = target;
|
TargetGO = target;
|
||||||
@ -34,7 +46,18 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
|||||||
return;
|
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
|
#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));
|
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 scrollLayout = scrollContent.GetComponent<VerticalLayoutGroup>();
|
||||||
var nameText = nameObj.GetComponent<Text>();
|
scrollLayout.childForceExpandHeight = false;
|
||||||
nameText.text = TargetGO.name;
|
scrollLayout.childControlHeight = true;
|
||||||
nameText.fontSize = 18;
|
scrollLayout.spacing = 5;
|
||||||
|
|
||||||
var childListObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
ConstructTopArea(scrollContent);
|
||||||
var childListText = childListObj.GetComponent<Text>();
|
|
||||||
childListText.text = "Children:";
|
|
||||||
|
|
||||||
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<HorizontalLayoutGroup>();
|
||||||
|
nameGroup.childForceExpandHeight = false;
|
||||||
|
nameGroup.childForceExpandWidth = false;
|
||||||
|
nameGroup.childControlHeight = false;
|
||||||
|
nameGroup.childControlWidth = true;
|
||||||
|
var nameRect = nameObj.GetComponent<RectTransform>();
|
||||||
|
nameRect.sizeDelta = new Vector2(nameRect.sizeDelta.x, 25);
|
||||||
|
var nameLayout = nameObj.AddComponent<LayoutElement>();
|
||||||
|
nameLayout.minHeight = 25;
|
||||||
|
nameLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
|
var nameTextObj = UIFactory.CreateTMPLabel(nameObj, TextAlignmentOptions.Left);
|
||||||
|
var nameTextText = nameTextObj.GetComponent<TextMeshProUGUI>();
|
||||||
|
nameTextText.text = "Name:";
|
||||||
|
nameTextText.fontSize = 14;
|
||||||
|
var nameTextLayout = nameTextObj.AddComponent<LayoutElement>();
|
||||||
|
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<RectTransform>();
|
||||||
|
nameInputRect.sizeDelta = new Vector2(nameInputRect.sizeDelta.x, 25);
|
||||||
|
m_nameInput = nameInputObj.GetComponent<TMP_InputField>();
|
||||||
|
m_nameInput.text = TargetGO.name;
|
||||||
|
m_nameInput.lineType = TMP_InputField.LineType.SingleLine;
|
||||||
|
|
||||||
|
var applyNameBtnObj = UIFactory.CreateButton(nameObj);
|
||||||
|
var applyNameBtn = applyNameBtnObj.GetComponent<Button>();
|
||||||
|
applyNameBtn.onClick.AddListener(new Action(() =>
|
||||||
{
|
{
|
||||||
var childLabelObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
TargetGO.name = m_nameInput.text;
|
||||||
var childLabelText = childLabelObj.GetComponent<Text>();
|
}));
|
||||||
childLabelText.text = " - " + child.name;
|
var applyNameText = applyNameBtnObj.GetComponentInChildren<Text>();
|
||||||
}
|
applyNameText.text = "Apply";
|
||||||
|
applyNameText.fontSize = 14;
|
||||||
|
var applyNameLayout = applyNameBtnObj.AddComponent<LayoutElement>();
|
||||||
|
applyNameLayout.minWidth = 65;
|
||||||
|
applyNameLayout.minHeight = 25;
|
||||||
|
applyNameLayout.flexibleHeight = 0;
|
||||||
|
var applyNameRect = applyNameBtnObj.GetComponent<RectTransform>();
|
||||||
|
applyNameRect.sizeDelta = new Vector2(applyNameRect.sizeDelta.x, 25);
|
||||||
|
|
||||||
var compListObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
// path row
|
||||||
var compListText = compListObj.GetComponent<Text>();
|
|
||||||
compListText.text = "Components:";
|
var pathObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||||
|
var pathGroup = pathObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
pathGroup.childForceExpandHeight = false;
|
||||||
|
pathGroup.childForceExpandWidth = false;
|
||||||
|
pathGroup.childControlHeight = false;
|
||||||
|
pathGroup.childControlWidth = true;
|
||||||
|
var pathRect = pathObj.GetComponent<RectTransform>();
|
||||||
|
pathRect.sizeDelta = new Vector2(pathRect.sizeDelta.x, 25);
|
||||||
|
var pathLayout = pathObj.AddComponent<LayoutElement>();
|
||||||
|
pathLayout.minHeight = 25;
|
||||||
|
pathLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
|
var pathTextObj = UIFactory.CreateTMPLabel(pathObj, TextAlignmentOptions.Left);
|
||||||
|
var pathTextText = pathTextObj.GetComponent<TextMeshProUGUI>();
|
||||||
|
pathTextText.text = "Path:";
|
||||||
|
pathTextText.fontSize = 14;
|
||||||
|
var pathTextLayout = pathTextObj.AddComponent<LayoutElement>();
|
||||||
|
pathTextLayout.minHeight = 25;
|
||||||
|
pathTextLayout.flexibleHeight = 0;
|
||||||
|
pathTextLayout.minWidth = 60;
|
||||||
|
pathTextLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
|
// TODO back button here (if has parent)
|
||||||
|
|
||||||
|
var pathInputObj = UIFactory.CreateTMPInput(pathObj, 14, 0, (int)TextAlignmentOptions.MidlineLeft);
|
||||||
|
var pathInputRect = pathInputObj.GetComponent<RectTransform>();
|
||||||
|
pathInputRect.sizeDelta = new Vector2(pathInputRect.sizeDelta.x, 25);
|
||||||
|
m_pathInput = pathInputObj.GetComponent<TMP_InputField>();
|
||||||
|
m_pathInput.text = TargetGO.transform.GetTransformPath();
|
||||||
|
var pathInputLayout = pathInputObj.AddComponent<LayoutElement>();
|
||||||
|
pathInputLayout.minHeight = 25;
|
||||||
|
pathInputLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
|
var applyPathBtnObj = UIFactory.CreateButton(pathObj);
|
||||||
|
var applyPathBtn = applyPathBtnObj.GetComponent<Button>();
|
||||||
|
applyNameBtn.onClick.AddListener(new Action(() =>
|
||||||
|
{
|
||||||
|
ExplorerCore.Log("TODO");
|
||||||
|
}));
|
||||||
|
var applyPathText = applyPathBtnObj.GetComponentInChildren<Text>();
|
||||||
|
applyPathText.text = "Apply";
|
||||||
|
applyPathText.fontSize = 14;
|
||||||
|
var applyBtnLayout = applyPathBtnObj.AddComponent<LayoutElement>();
|
||||||
|
applyBtnLayout.minWidth = 65;
|
||||||
|
applyBtnLayout.minHeight = 25;
|
||||||
|
applyBtnLayout.flexibleHeight = 0;
|
||||||
|
var applyBtnRect = applyPathBtnObj.GetComponent<RectTransform>();
|
||||||
|
applyBtnRect.sizeDelta = new Vector2(applyNameRect.sizeDelta.x, 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConstructChildList(GameObject scrollContent)
|
||||||
|
{
|
||||||
|
// todo put this in a RefreshChildren method, and use page handler
|
||||||
|
|
||||||
|
var childTitleObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||||
|
var childTitleText = childTitleObj.GetComponent<Text>();
|
||||||
|
childTitleText.text = "Children:";
|
||||||
|
|
||||||
|
var childrenScrollObj = UIFactory.CreateScrollView(scrollContent, out GameObject subContent, new Color(0.15f, 0.15f, 0.15f));
|
||||||
|
var contentLayout = childrenScrollObj.AddComponent<LayoutElement>();
|
||||||
|
contentLayout.minHeight = 50;
|
||||||
|
contentLayout.flexibleHeight = 10000;
|
||||||
|
|
||||||
|
var contentGroup = subContent.GetComponent<VerticalLayoutGroup>();
|
||||||
|
contentGroup.spacing = 4;
|
||||||
|
|
||||||
|
for (int i = 0; i < TargetGO.transform.childCount; i++)
|
||||||
|
{
|
||||||
|
var child = TargetGO.transform.GetChild(i);
|
||||||
|
|
||||||
|
var buttonObj = UIFactory.CreateButton(subContent);
|
||||||
|
|
||||||
|
var btnImage = buttonObj.GetComponent<Image>();
|
||||||
|
btnImage.color = new Color(0.15f, 0.15f, 0.15f);
|
||||||
|
|
||||||
|
var button = buttonObj.GetComponent<Button>();
|
||||||
|
button.onClick.AddListener(new Action(() =>
|
||||||
|
{
|
||||||
|
ChangeInspectorTarget(child?.gameObject);
|
||||||
|
}));
|
||||||
|
|
||||||
|
var buttonText = buttonObj.GetComponentInChildren<Text>();
|
||||||
|
var text = child.name;
|
||||||
|
if (child.childCount > 0)
|
||||||
|
text = $"<color=grey>[{child.childCount}]</color> {text}";
|
||||||
|
buttonText.text = text;
|
||||||
|
buttonText.color = child.gameObject.activeSelf ? Color.green : Color.red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConstructCompList(GameObject scrollContent)
|
||||||
|
{
|
||||||
|
// todo put this in a RefreshComponents method, and use page handler
|
||||||
|
|
||||||
|
var compTitleObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||||
|
var compTitleText = compTitleObj.GetComponent<Text>();
|
||||||
|
compTitleText.text = "Components:";
|
||||||
|
|
||||||
|
var compScrollObj = UIFactory.CreateScrollView(scrollContent, out GameObject subContent, new Color(0.15f, 0.15f, 0.15f));
|
||||||
|
var contentLayout = compScrollObj.AddComponent<LayoutElement>();
|
||||||
|
contentLayout.minHeight = 50;
|
||||||
|
contentLayout.flexibleHeight = 10000;
|
||||||
|
|
||||||
|
var contentGroup = subContent.GetComponent<VerticalLayoutGroup>();
|
||||||
|
contentGroup.spacing = 4;
|
||||||
|
|
||||||
foreach (var comp in TargetGO.GetComponents<Component>())
|
foreach (var comp in TargetGO.GetComponents<Component>())
|
||||||
{
|
{
|
||||||
var compLabelObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
var buttonObj = UIFactory.CreateButton(subContent);
|
||||||
var compText = compLabelObj.GetComponent<Text>();
|
|
||||||
compText.text = " - " + comp.GetType().Name;
|
var btnImage = buttonObj.GetComponent<Image>();
|
||||||
|
btnImage.color = new Color(0.15f, 0.15f, 0.15f);
|
||||||
|
|
||||||
|
var button = buttonObj.GetComponent<Button>();
|
||||||
|
button.onClick.AddListener(new Action(() =>
|
||||||
|
{
|
||||||
|
InspectorManager.Instance.Inspect(comp);
|
||||||
|
}));
|
||||||
|
|
||||||
|
var buttonText = buttonObj.GetComponentInChildren<Text>();
|
||||||
|
buttonText.text = ReflectionHelpers.GetActualType(comp).FullName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConstructControls(GameObject scrollContent)
|
||||||
|
{
|
||||||
|
// todo GO controls
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -59,14 +59,22 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
|||||||
GameObject.Destroy(Content);
|
GameObject.Destroy(Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int thisIndex = -1;
|
||||||
|
if (InspectorManager.Instance.m_currentInspectors.Contains(this))
|
||||||
|
{
|
||||||
|
thisIndex = InspectorManager.Instance.m_currentInspectors.IndexOf(this);
|
||||||
|
InspectorManager.Instance.m_currentInspectors.Remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (ReferenceEquals(InspectorManager.Instance.m_activeInspector, this))
|
if (ReferenceEquals(InspectorManager.Instance.m_activeInspector, this))
|
||||||
{
|
{
|
||||||
InspectorManager.Instance.UnsetInspectorTab();
|
InspectorManager.Instance.UnsetInspectorTab();
|
||||||
}
|
|
||||||
|
|
||||||
if (InspectorManager.Instance.m_currentInspectors.Contains(this))
|
if (InspectorManager.Instance.m_currentInspectors.Count > 0)
|
||||||
{
|
{
|
||||||
InspectorManager.Instance.m_currentInspectors.Remove(this);
|
var prevTab = InspectorManager.Instance.m_currentInspectors[thisIndex > 0 ? thisIndex - 1 : 0];
|
||||||
|
InspectorManager.Instance.SetInspectorTab(prevTab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,6 @@ namespace ExplorerBeta.UI.Main
|
|||||||
m_lastResizeHoverType = resizeType;
|
m_lastResizeHoverType = resizeType;
|
||||||
|
|
||||||
m_resizeCursorImage.SetActive(true);
|
m_resizeCursorImage.SetActive(true);
|
||||||
ExplorerCore.Log("Set image active.");
|
|
||||||
|
|
||||||
// set the rotation for the resize icon
|
// set the rotation for the resize icon
|
||||||
float iconRotation = 0f;
|
float iconRotation = 0f;
|
||||||
|
@ -142,15 +142,14 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
if (!handles.Contains(m_currentSceneHandle))
|
if (!handles.Contains(m_currentSceneHandle))
|
||||||
{
|
{
|
||||||
ExplorerCore.Log("Reverting to default scene");
|
|
||||||
m_sceneDropdown.transform.Find("Label").GetComponent<Text>().text = names[0];
|
m_sceneDropdown.transform.Find("Label").GetComponent<Text>().text = names[0];
|
||||||
SetScene(handles[0]);
|
SetTargetScene(handles[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScene(string name) => SetScene(GetSceneHandle(name));
|
public void SetTargetScene(string name) => SetTargetScene(GetSceneHandle(name));
|
||||||
|
|
||||||
public void SetScene(int handle)
|
public void SetTargetScene(int handle)
|
||||||
{
|
{
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
return;
|
return;
|
||||||
@ -172,8 +171,11 @@ namespace ExplorerBeta.UI.Main
|
|||||||
//m_scenePathText.ForceMeshUpdate();
|
//m_scenePathText.ForceMeshUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSceneListObject(GameObject obj)
|
public void SetTargetObject(GameObject obj)
|
||||||
{
|
{
|
||||||
|
if (!obj)
|
||||||
|
return;
|
||||||
|
|
||||||
m_scenePathText.text = obj.name;
|
m_scenePathText.text = obj.name;
|
||||||
//m_scenePathText.ForceMeshUpdate();
|
//m_scenePathText.ForceMeshUpdate();
|
||||||
|
|
||||||
@ -195,7 +197,7 @@ namespace ExplorerBeta.UI.Main
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSceneListObject(m_sceneShortList[index]);
|
SetTargetObject(m_sceneShortList[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSceneListPageTurn()
|
private void OnSceneListPageTurn()
|
||||||
@ -242,10 +244,13 @@ namespace ExplorerBeta.UI.Main
|
|||||||
{
|
{
|
||||||
GameObject obj = objects[i + startIndex];
|
GameObject obj = objects[i + startIndex];
|
||||||
|
|
||||||
|
if (!obj)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (i >= m_sceneShortList.Count)
|
if (i >= m_sceneShortList.Count)
|
||||||
{
|
{
|
||||||
m_sceneShortList.Add(obj);
|
m_sceneShortList.Add(obj);
|
||||||
AddSceneButton();
|
AddObjectListButton();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -316,7 +321,7 @@ namespace ExplorerBeta.UI.Main
|
|||||||
void SetSceneFromDropdown(int val)
|
void SetSceneFromDropdown(int val)
|
||||||
{
|
{
|
||||||
string scene = m_sceneDropdown.options[val].text;
|
string scene = m_sceneDropdown.options[val].text;
|
||||||
SetScene(scene);
|
SetTargetScene(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f));
|
GameObject scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f));
|
||||||
@ -346,14 +351,14 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
void SetSceneObjectParent()
|
void SetSceneObjectParent()
|
||||||
{
|
{
|
||||||
if (!m_selectedSceneObject || !m_selectedSceneObject.transform.parent)
|
if (!m_selectedSceneObject || !m_selectedSceneObject.transform.parent?.gameObject)
|
||||||
{
|
{
|
||||||
m_selectedSceneObject = null;
|
m_selectedSceneObject = null;
|
||||||
SetScene(m_currentSceneHandle);
|
SetTargetScene(m_currentSceneHandle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetSceneListObject(m_selectedSceneObject.transform.parent.gameObject);
|
SetTargetObject(m_selectedSceneObject.transform.parent.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +405,13 @@ namespace ExplorerBeta.UI.Main
|
|||||||
colors.normalColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
|
colors.normalColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
|
||||||
scroll.colors = colors;
|
scroll.colors = colors;
|
||||||
|
|
||||||
VerticalLayoutGroup sceneGroup = m_sceneListCanvas.GetComponent<VerticalLayoutGroup>();
|
var horiScroll = scrollObj.transform.Find("Scrollbar Horizontal");
|
||||||
|
horiScroll.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
var scrollRect = scrollObj.GetComponentInChildren<ScrollRect>();
|
||||||
|
scrollRect.horizontalScrollbar = null;
|
||||||
|
|
||||||
|
var sceneGroup = m_sceneListCanvas.GetComponent<VerticalLayoutGroup>();
|
||||||
sceneGroup.childControlHeight = true;
|
sceneGroup.childControlHeight = true;
|
||||||
sceneGroup.spacing = 2;
|
sceneGroup.spacing = 2;
|
||||||
|
|
||||||
@ -409,7 +420,7 @@ namespace ExplorerBeta.UI.Main
|
|||||||
m_sceneListPageHandler.OnPageChanged += OnSceneListPageTurn;
|
m_sceneListPageHandler.OnPageChanged += OnSceneListPageTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddSceneButton()
|
private void AddObjectListButton()
|
||||||
{
|
{
|
||||||
int thisIndex = m_sceneListTexts.Count();
|
int thisIndex = m_sceneListTexts.Count();
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ namespace ExplorerBeta.UI
|
|||||||
return toggleObj;
|
return toggleObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject CreateTMPInput(GameObject parent)
|
public static GameObject CreateTMPInput(GameObject parent, int fontSize = 16, int overflowMode = 0, int alignment = 257)
|
||||||
{
|
{
|
||||||
GameObject mainObj = CreateUIObject("InputField (TMP)", parent);
|
GameObject mainObj = CreateUIObject("InputField (TMP)", parent);
|
||||||
|
|
||||||
@ -436,9 +436,11 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
GameObject placeHolderObj = CreateUIObject("Placeholder", textArea);
|
GameObject placeHolderObj = CreateUIObject("Placeholder", textArea);
|
||||||
TextMeshProUGUI placeholderText = placeHolderObj.AddComponent<TextMeshProUGUI>();
|
TextMeshProUGUI placeholderText = placeHolderObj.AddComponent<TextMeshProUGUI>();
|
||||||
placeholderText.fontSize = 16;
|
placeholderText.fontSize = fontSize;
|
||||||
placeholderText.text = "...";
|
placeholderText.text = "...";
|
||||||
placeholderText.color = new Color(0.5f, 0.5f, 0.5f, 1.0f);
|
placeholderText.color = new Color(0.5f, 0.5f, 0.5f, 1.0f);
|
||||||
|
placeholderText.overflowMode = (TextOverflowModes)overflowMode;
|
||||||
|
placeholderText.alignment = (TextAlignmentOptions)alignment;
|
||||||
|
|
||||||
RectTransform placeHolderRect = placeHolderObj.GetComponent<RectTransform>();
|
RectTransform placeHolderRect = placeHolderObj.GetComponent<RectTransform>();
|
||||||
placeHolderRect.anchorMin = Vector2.zero;
|
placeHolderRect.anchorMin = Vector2.zero;
|
||||||
@ -454,9 +456,11 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
GameObject inputTextObj = CreateUIObject("Text", textArea);
|
GameObject inputTextObj = CreateUIObject("Text", textArea);
|
||||||
TextMeshProUGUI inputText = inputTextObj.AddComponent<TextMeshProUGUI>();
|
TextMeshProUGUI inputText = inputTextObj.AddComponent<TextMeshProUGUI>();
|
||||||
inputText.fontSize = 16;
|
inputText.fontSize = fontSize;
|
||||||
inputText.text = "";
|
inputText.text = "";
|
||||||
inputText.color = new Color(1f, 1f, 1f, 1f);
|
inputText.color = new Color(1f, 1f, 1f, 1f);
|
||||||
|
inputText.overflowMode = (TextOverflowModes)overflowMode;
|
||||||
|
inputText.alignment = (TextAlignmentOptions)alignment;
|
||||||
|
|
||||||
RectTransform inputTextRect = inputTextObj.GetComponent<RectTransform>();
|
RectTransform inputTextRect = inputTextObj.GetComponent<RectTransform>();
|
||||||
inputTextRect.anchorMin = Vector2.zero;
|
inputTextRect.anchorMin = Vector2.zero;
|
||||||
@ -464,9 +468,9 @@ namespace ExplorerBeta.UI
|
|||||||
inputTextRect.offsetMin = Vector2.zero;
|
inputTextRect.offsetMin = Vector2.zero;
|
||||||
inputTextRect.offsetMax = Vector2.zero;
|
inputTextRect.offsetMax = Vector2.zero;
|
||||||
|
|
||||||
LayoutElement test = inputTextObj.AddComponent<LayoutElement>();
|
LayoutElement inputTextLayout = inputTextObj.AddComponent<LayoutElement>();
|
||||||
test.preferredWidth = 990;
|
inputTextLayout.preferredWidth = 990;
|
||||||
test.flexibleWidth = 500;
|
inputTextLayout.flexibleWidth = 500;
|
||||||
|
|
||||||
mainInput.textComponent = inputText;
|
mainInput.textComponent = inputText;
|
||||||
|
|
||||||
@ -523,6 +527,7 @@ namespace ExplorerBeta.UI
|
|||||||
GameObject dropdownObj = CreateUIObject("Dropdown", parent, thickSize);
|
GameObject dropdownObj = CreateUIObject("Dropdown", parent, thickSize);
|
||||||
|
|
||||||
GameObject labelObj = CreateUIObject("Label", dropdownObj);
|
GameObject labelObj = CreateUIObject("Label", dropdownObj);
|
||||||
|
GameObject arrowObj = CreateUIObject("Arrow", dropdownObj);
|
||||||
GameObject templateObj = CreateUIObject("Template", dropdownObj);
|
GameObject templateObj = CreateUIObject("Template", dropdownObj);
|
||||||
GameObject viewportObj = CreateUIObject("Viewport", templateObj);
|
GameObject viewportObj = CreateUIObject("Viewport", templateObj);
|
||||||
GameObject contentObj = CreateUIObject("Content", viewportObj);
|
GameObject contentObj = CreateUIObject("Content", viewportObj);
|
||||||
@ -546,6 +551,15 @@ namespace ExplorerBeta.UI
|
|||||||
SetDefaultTextValues(itemLabelText);
|
SetDefaultTextValues(itemLabelText);
|
||||||
itemLabelText.alignment = TextAnchor.MiddleLeft;
|
itemLabelText.alignment = TextAnchor.MiddleLeft;
|
||||||
|
|
||||||
|
var arrowText = arrowObj.AddComponent<Text>();
|
||||||
|
SetDefaultTextValues(arrowText);
|
||||||
|
arrowText.text = "▼";
|
||||||
|
var arrowRect = arrowObj.GetComponent<RectTransform>();
|
||||||
|
arrowRect.anchorMin = new Vector2(1f, 0.5f);
|
||||||
|
arrowRect.anchorMax = new Vector2(1f, 0.5f);
|
||||||
|
arrowRect.sizeDelta = new Vector2(20f, 20f);
|
||||||
|
arrowRect.anchoredPosition = new Vector2(-15f, 0f);
|
||||||
|
|
||||||
Image itemBgImage = itemBgObj.AddComponent<Image>();
|
Image itemBgImage = itemBgObj.AddComponent<Image>();
|
||||||
itemBgImage.color = new Color(0.25f, 0.45f, 0.25f, 1.0f);
|
itemBgImage.color = new Color(0.25f, 0.45f, 0.25f, 1.0f);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ namespace ExplorerBeta.Unstrip.Scenes
|
|||||||
{
|
{
|
||||||
public class SceneUnstrip
|
public class SceneUnstrip
|
||||||
{
|
{
|
||||||
|
#if MONO
|
||||||
public static GameObject[] GetRootGameObjects(Scene scene) => scene.GetRootGameObjects();
|
public static GameObject[] GetRootGameObjects(Scene scene) => scene.GetRootGameObjects();
|
||||||
|
|
||||||
public static GameObject[] GetRootGameObjects(int handle)
|
public static GameObject[] GetRootGameObjects(int handle)
|
||||||
@ -22,6 +23,7 @@ namespace ExplorerBeta.Unstrip.Scenes
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Scene.GetRootGameObjects();
|
//Scene.GetRootGameObjects();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
internal delegate void d_GetRootGameObjects(int handle, IntPtr list);
|
internal delegate void d_GetRootGameObjects(int handle, IntPtr list);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user