2020-10-28 06:39:26 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
using UnityExplorer.Helpers;
|
|
|
|
|
using UnityExplorer.UI.Main.Inspectors;
|
|
|
|
|
using UnityExplorer.UI.Shared;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
using UnityEngine.UI;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
using UnityExplorer.Unstrip.Scenes;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
namespace UnityExplorer.UI.Main
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
public class SceneExplorer
|
|
|
|
|
{
|
|
|
|
|
public static SceneExplorer Instance;
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
public SceneExplorer()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
ConstructScenePane();
|
|
|
|
|
}
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
|
|
|
|
private const float UPDATE_INTERVAL = 1f;
|
|
|
|
|
private float m_timeOfLastSceneUpdate;
|
|
|
|
|
|
|
|
|
|
private GameObject m_selectedSceneObject;
|
2020-10-28 20:52:40 +11:00
|
|
|
|
private int m_currentSceneHandle = -1;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
private int m_lastCount;
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
private Dropdown m_sceneDropdown;
|
|
|
|
|
private Text m_scenePathText;
|
|
|
|
|
private GameObject m_mainInspectBtn;
|
|
|
|
|
private GameObject m_backButtonObj;
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
public PageHandler m_sceneListPageHandler;
|
|
|
|
|
|
|
|
|
|
private GameObject[] m_allSceneListObjects = new GameObject[0];
|
|
|
|
|
private readonly List<GameObject> m_sceneShortList = new List<GameObject>();
|
2020-11-03 20:59:13 +11:00
|
|
|
|
private GameObject m_sceneListContent;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
public static int DontDestroyHandle => DontDestroyObject.scene.handle;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
internal static GameObject DontDestroyObject
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (!m_dontDestroyObject)
|
|
|
|
|
{
|
|
|
|
|
m_dontDestroyObject = new GameObject("DontDestroyMe");
|
|
|
|
|
GameObject.DontDestroyOnLoad(m_dontDestroyObject);
|
|
|
|
|
}
|
|
|
|
|
return m_dontDestroyObject;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
internal static GameObject m_dontDestroyObject;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
RefreshActiveScenes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
if (Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshActiveScenes();
|
|
|
|
|
|
|
|
|
|
if (!m_selectedSceneObject)
|
|
|
|
|
{
|
|
|
|
|
if (m_currentSceneHandle != -1)
|
|
|
|
|
{
|
|
|
|
|
SetSceneObjectList(SceneUnstrip.GetRootGameObjects(m_currentSceneHandle));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RefreshSelectedSceneObject();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
public int GetSceneHandle(string sceneName)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
if (sceneName == "DontDestroyOnLoad")
|
|
|
|
|
return DontDestroyHandle;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
var scene = SceneManager.GetSceneAt(i);
|
|
|
|
|
if (scene.name == sceneName)
|
|
|
|
|
return scene.handle;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
2020-10-28 20:52:40 +11:00
|
|
|
|
return -1;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void OnSceneChange()
|
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
m_sceneDropdown.OnCancel(null);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
RefreshActiveScenes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshActiveScenes()
|
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
var names = new List<string>();
|
|
|
|
|
var handles = new List<int>();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
|
|
|
|
{
|
|
|
|
|
Scene scene = SceneManager.GetSceneAt(i);
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
int handle = scene.handle;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
if (scene == null || handle == -1 || string.IsNullOrEmpty(scene.name))
|
|
|
|
|
continue;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
handles.Add(handle);
|
|
|
|
|
names.Add(scene.name);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
names.Add("DontDestroyOnLoad");
|
|
|
|
|
handles.Add(DontDestroyHandle);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
m_sceneDropdown.options.Clear();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
foreach (string scene in names)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
|
|
|
|
{
|
|
|
|
|
text = scene
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
if (!handles.Contains(m_currentSceneHandle))
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
m_sceneDropdown.transform.Find("Label").GetComponent<Text>().text = names[0];
|
2020-11-02 20:48:53 +11:00
|
|
|
|
SetTargetScene(handles[0]);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 20:48:53 +11:00
|
|
|
|
public void SetTargetScene(string name) => SetTargetScene(GetSceneHandle(name));
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-02 20:48:53 +11:00
|
|
|
|
public void SetTargetScene(int handle)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
if (handle == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_currentSceneHandle = handle;
|
|
|
|
|
|
|
|
|
|
GameObject[] rootObjs = SceneUnstrip.GetRootGameObjects(handle);
|
|
|
|
|
SetSceneObjectList(rootObjs);
|
|
|
|
|
|
|
|
|
|
m_selectedSceneObject = null;
|
|
|
|
|
|
|
|
|
|
if (m_backButtonObj.activeSelf)
|
|
|
|
|
{
|
|
|
|
|
m_backButtonObj.SetActive(false);
|
|
|
|
|
m_mainInspectBtn.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_scenePathText.text = "Scene root:";
|
|
|
|
|
//m_scenePathText.ForceMeshUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 20:48:53 +11:00
|
|
|
|
public void SetTargetObject(GameObject obj)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-11-02 20:48:53 +11:00
|
|
|
|
if (!obj)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
m_scenePathText.text = obj.name;
|
|
|
|
|
//m_scenePathText.ForceMeshUpdate();
|
|
|
|
|
|
|
|
|
|
m_selectedSceneObject = obj;
|
|
|
|
|
|
|
|
|
|
RefreshSelectedSceneObject();
|
|
|
|
|
|
|
|
|
|
if (!m_backButtonObj.activeSelf)
|
|
|
|
|
{
|
|
|
|
|
m_backButtonObj.SetActive(true);
|
|
|
|
|
m_mainInspectBtn.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
private void RefreshSelectedSceneObject()
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
GameObject[] list = new GameObject[m_selectedSceneObject.transform.childCount];
|
|
|
|
|
for (int i = 0; i < m_selectedSceneObject.transform.childCount; i++)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
list[i] = m_selectedSceneObject.transform.GetChild(i).gameObject;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
SetSceneObjectList(list);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
private void SetSceneObjectList(GameObject[] objects)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
m_allSceneListObjects = objects;
|
|
|
|
|
RefreshSceneObjectList();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
private void SceneListObjectClicked(int index)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
if (index >= m_sceneShortList.Count || !m_sceneShortList[index])
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
return;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
SetTargetObject(m_sceneShortList[index]);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
private void OnSceneListPageTurn()
|
|
|
|
|
{
|
|
|
|
|
RefreshSceneObjectList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshSceneObjectList()
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
m_timeOfLastSceneUpdate = Time.realtimeSinceStartup;
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
var objects = m_allSceneListObjects;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
m_sceneListPageHandler.ListCount = objects.Length;
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
//int startIndex = m_sceneListPageHandler.StartIndex;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
|
|
|
|
int newCount = 0;
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
foreach (var itemIndex in m_sceneListPageHandler)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
newCount++;
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
// normalized index starting from 0
|
|
|
|
|
var i = itemIndex - m_sceneListPageHandler.StartIndex;
|
|
|
|
|
|
|
|
|
|
if (itemIndex >= objects.Length)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
if (i > m_lastCount || i >= m_sceneListTexts.Count)
|
|
|
|
|
break;
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
GameObject label = m_sceneListTexts[i].transform.parent.parent.gameObject;
|
|
|
|
|
if (label.activeSelf)
|
|
|
|
|
label.SetActive(false);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
GameObject obj = objects[itemIndex];
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-02 20:48:53 +11:00
|
|
|
|
if (!obj)
|
|
|
|
|
continue;
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
if (i >= m_sceneShortList.Count)
|
|
|
|
|
{
|
|
|
|
|
m_sceneShortList.Add(obj);
|
2020-11-02 20:48:53 +11:00
|
|
|
|
AddObjectListButton();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_sceneShortList[i] = obj;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
var text = m_sceneListTexts[i];
|
|
|
|
|
|
|
|
|
|
var name = obj.name;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
if (obj.transform.childCount > 0)
|
|
|
|
|
name = $"<color=grey>[{obj.transform.childCount}]</color> {name}";
|
|
|
|
|
|
|
|
|
|
text.text = name;
|
|
|
|
|
text.color = obj.activeSelf ? Color.green : Color.red;
|
|
|
|
|
|
|
|
|
|
var label = text.transform.parent.parent.gameObject;
|
|
|
|
|
if (!label.activeSelf)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
label.SetActive(true);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_lastCount = newCount;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
#region UI CONSTRUCTION
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
|
|
|
|
public void ConstructScenePane()
|
|
|
|
|
{
|
|
|
|
|
GameObject leftPane = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
|
|
|
|
LayoutElement leftLayout = leftPane.AddComponent<LayoutElement>();
|
|
|
|
|
leftLayout.minWidth = 350;
|
|
|
|
|
leftLayout.flexibleWidth = 0;
|
|
|
|
|
|
|
|
|
|
VerticalLayoutGroup leftGroup = leftPane.GetComponent<VerticalLayoutGroup>();
|
|
|
|
|
leftGroup.padding.left = 8;
|
|
|
|
|
leftGroup.padding.right = 8;
|
|
|
|
|
leftGroup.padding.top = 8;
|
|
|
|
|
leftGroup.padding.bottom = 8;
|
|
|
|
|
leftGroup.spacing = 5;
|
|
|
|
|
leftGroup.childControlWidth = true;
|
|
|
|
|
leftGroup.childControlHeight = true;
|
|
|
|
|
leftGroup.childForceExpandWidth = true;
|
|
|
|
|
leftGroup.childForceExpandHeight = true;
|
|
|
|
|
|
|
|
|
|
GameObject titleObj = UIFactory.CreateLabel(leftPane, TextAnchor.UpperLeft);
|
|
|
|
|
Text titleLabel = titleObj.GetComponent<Text>();
|
|
|
|
|
titleLabel.text = "Scene Explorer";
|
|
|
|
|
titleLabel.fontSize = 20;
|
|
|
|
|
LayoutElement titleLayout = titleObj.AddComponent<LayoutElement>();
|
|
|
|
|
titleLayout.minHeight = 30;
|
|
|
|
|
titleLayout.flexibleHeight = 0;
|
|
|
|
|
|
|
|
|
|
GameObject sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown);
|
|
|
|
|
LayoutElement dropdownLayout = sceneDropdownObj.AddComponent<LayoutElement>();
|
|
|
|
|
dropdownLayout.minHeight = 40;
|
|
|
|
|
dropdownLayout.flexibleHeight = 0;
|
|
|
|
|
dropdownLayout.minWidth = 320;
|
|
|
|
|
dropdownLayout.flexibleWidth = 2;
|
|
|
|
|
|
|
|
|
|
#if CPP
|
|
|
|
|
m_sceneDropdown.onValueChanged.AddListener(new Action<int>((int val) => { SetSceneFromDropdown(val); }));
|
|
|
|
|
#else
|
|
|
|
|
m_sceneDropdown.onValueChanged.AddListener((int val) => { SetSceneFromDropdown(val); });
|
|
|
|
|
#endif
|
|
|
|
|
void SetSceneFromDropdown(int val)
|
|
|
|
|
{
|
|
|
|
|
string scene = m_sceneDropdown.options[val].text;
|
2020-11-02 20:48:53 +11:00
|
|
|
|
SetTargetScene(scene);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GameObject scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f));
|
|
|
|
|
HorizontalLayoutGroup scenePathGroup = scenePathGroupObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
scenePathGroup.childControlHeight = true;
|
|
|
|
|
scenePathGroup.childControlWidth = true;
|
|
|
|
|
scenePathGroup.childForceExpandHeight = true;
|
|
|
|
|
scenePathGroup.childForceExpandWidth = true;
|
|
|
|
|
scenePathGroup.spacing = 5;
|
|
|
|
|
LayoutElement scenePathLayout = scenePathGroupObj.AddComponent<LayoutElement>();
|
|
|
|
|
scenePathLayout.minHeight = 20;
|
|
|
|
|
scenePathLayout.minWidth = 335;
|
|
|
|
|
scenePathLayout.flexibleWidth = 0;
|
|
|
|
|
|
|
|
|
|
m_backButtonObj = UIFactory.CreateButton(scenePathGroupObj);
|
|
|
|
|
Text backButtonText = m_backButtonObj.GetComponentInChildren<Text>();
|
|
|
|
|
backButtonText.text = "<";
|
|
|
|
|
LayoutElement backButtonLayout = m_backButtonObj.AddComponent<LayoutElement>();
|
|
|
|
|
backButtonLayout.minWidth = 40;
|
|
|
|
|
backButtonLayout.flexibleWidth = 0;
|
|
|
|
|
Button backButton = m_backButtonObj.GetComponent<Button>();
|
|
|
|
|
#if CPP
|
|
|
|
|
backButton.onClick.AddListener(new Action(() => { SetSceneObjectParent(); }));
|
|
|
|
|
#else
|
|
|
|
|
backButton.onClick.AddListener(() => { SetSceneObjectParent(); });
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void SetSceneObjectParent()
|
|
|
|
|
{
|
2020-11-02 20:48:53 +11:00
|
|
|
|
if (!m_selectedSceneObject || !m_selectedSceneObject.transform.parent?.gameObject)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
m_selectedSceneObject = null;
|
2020-11-02 20:48:53 +11:00
|
|
|
|
SetTargetScene(m_currentSceneHandle);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-11-02 20:48:53 +11:00
|
|
|
|
SetTargetObject(m_selectedSceneObject.transform.parent.gameObject);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GameObject scenePathLabel = UIFactory.CreateHorizontalGroup(scenePathGroupObj);
|
|
|
|
|
Image image = scenePathLabel.GetComponent<Image>();
|
|
|
|
|
image.color = Color.white;
|
|
|
|
|
|
|
|
|
|
LayoutElement scenePathLabelLayout = scenePathLabel.AddComponent<LayoutElement>();
|
|
|
|
|
scenePathLabelLayout.minWidth = 210;
|
|
|
|
|
scenePathLabelLayout.minHeight = 20;
|
|
|
|
|
scenePathLabelLayout.flexibleHeight = 0;
|
|
|
|
|
scenePathLabelLayout.flexibleWidth = 120;
|
|
|
|
|
|
|
|
|
|
scenePathLabel.AddComponent<Mask>().showMaskGraphic = false;
|
|
|
|
|
|
|
|
|
|
GameObject scenePathLabelText = UIFactory.CreateLabel(scenePathLabel, TextAnchor.MiddleLeft);
|
|
|
|
|
m_scenePathText = scenePathLabelText.GetComponent<Text>();
|
|
|
|
|
m_scenePathText.text = "Scene root:";
|
|
|
|
|
m_scenePathText.fontSize = 15;
|
|
|
|
|
m_scenePathText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
|
|
|
|
|
|
|
|
|
LayoutElement textLayout = scenePathLabelText.gameObject.AddComponent<LayoutElement>();
|
|
|
|
|
textLayout.minWidth = 210;
|
|
|
|
|
textLayout.flexibleWidth = 120;
|
|
|
|
|
textLayout.minHeight = 20;
|
|
|
|
|
textLayout.flexibleHeight = 0;
|
|
|
|
|
|
|
|
|
|
m_mainInspectBtn = UIFactory.CreateButton(scenePathGroupObj);
|
|
|
|
|
Text inspectButtonText = m_mainInspectBtn.GetComponentInChildren<Text>();
|
|
|
|
|
inspectButtonText.text = "Inspect";
|
|
|
|
|
LayoutElement inspectButtonLayout = m_mainInspectBtn.AddComponent<LayoutElement>();
|
|
|
|
|
inspectButtonLayout.minWidth = 65;
|
|
|
|
|
inspectButtonLayout.flexibleWidth = 0;
|
|
|
|
|
Button inspectButton = m_mainInspectBtn.GetComponent<Button>();
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#if CPP
|
2020-10-28 06:39:26 +11:00
|
|
|
|
inspectButton.onClick.AddListener(new Action(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); }));
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#else
|
|
|
|
|
inspectButton.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); });
|
|
|
|
|
#endif
|
2020-11-03 20:59:13 +11:00
|
|
|
|
GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_sceneListContent, new Color(0.1f, 0.1f, 0.1f));
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Scrollbar scroll = scrollObj.transform.Find("Scrollbar Vertical").GetComponent<Scrollbar>();
|
|
|
|
|
ColorBlock colors = scroll.colors;
|
|
|
|
|
colors.normalColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
|
|
|
|
|
scroll.colors = colors;
|
|
|
|
|
|
2020-11-02 20:48:53 +11:00
|
|
|
|
var horiScroll = scrollObj.transform.Find("Scrollbar Horizontal");
|
|
|
|
|
horiScroll.gameObject.SetActive(false);
|
|
|
|
|
|
|
|
|
|
var scrollRect = scrollObj.GetComponentInChildren<ScrollRect>();
|
|
|
|
|
scrollRect.horizontalScrollbar = null;
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
var sceneGroup = m_sceneListContent.GetComponent<VerticalLayoutGroup>();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
sceneGroup.childControlHeight = true;
|
|
|
|
|
sceneGroup.spacing = 2;
|
|
|
|
|
|
|
|
|
|
m_sceneListPageHandler = new PageHandler();
|
|
|
|
|
m_sceneListPageHandler.ConstructUI(leftPane);
|
|
|
|
|
m_sceneListPageHandler.OnPageChanged += OnSceneListPageTurn;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 20:48:53 +11:00
|
|
|
|
private void AddObjectListButton()
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
int thisIndex = m_sceneListTexts.Count();
|
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_sceneListContent, new Color(0.1f, 0.1f, 0.1f));
|
2020-10-28 06:39:26 +11:00
|
|
|
|
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
btnGroup.childForceExpandWidth = true;
|
|
|
|
|
btnGroup.childControlWidth = true;
|
|
|
|
|
btnGroup.childForceExpandHeight = false;
|
|
|
|
|
btnGroup.childControlHeight = true;
|
|
|
|
|
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
|
|
|
|
|
btnLayout.flexibleWidth = 320;
|
|
|
|
|
btnLayout.minHeight = 25;
|
|
|
|
|
btnLayout.flexibleHeight = 0;
|
|
|
|
|
btnGroupObj.AddComponent<Mask>();
|
|
|
|
|
|
|
|
|
|
GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj);
|
|
|
|
|
LayoutElement mainBtnLayout = mainButtonObj.AddComponent<LayoutElement>();
|
|
|
|
|
mainBtnLayout.minHeight = 25;
|
|
|
|
|
mainBtnLayout.flexibleHeight = 0;
|
|
|
|
|
mainBtnLayout.minWidth = 240;
|
|
|
|
|
mainBtnLayout.flexibleWidth = 0;
|
|
|
|
|
Button mainBtn = mainButtonObj.GetComponent<Button>();
|
|
|
|
|
ColorBlock mainColors = mainBtn.colors;
|
2020-10-28 07:14:00 +11:00
|
|
|
|
mainColors.normalColor = new Color(0.1f, 0.1f, 0.1f);
|
|
|
|
|
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
mainBtn.colors = mainColors;
|
|
|
|
|
#if CPP
|
|
|
|
|
mainBtn.onClick.AddListener(new Action(() => { SceneListObjectClicked(thisIndex); }));
|
|
|
|
|
#else
|
2020-10-28 20:52:40 +11:00
|
|
|
|
mainBtn.onClick.AddListener(() => { SceneListObjectClicked(thisIndex); });
|
2020-10-28 06:39:26 +11:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
|
|
|
|
mainText.alignment = TextAnchor.MiddleLeft;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
mainText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
m_sceneListTexts.Add(mainText);
|
|
|
|
|
|
|
|
|
|
GameObject inspectBtnObj = UIFactory.CreateButton(btnGroupObj);
|
|
|
|
|
LayoutElement inspectBtnLayout = inspectBtnObj.AddComponent<LayoutElement>();
|
|
|
|
|
inspectBtnLayout.minWidth = 60;
|
|
|
|
|
inspectBtnLayout.flexibleWidth = 0;
|
|
|
|
|
inspectBtnLayout.minHeight = 25;
|
|
|
|
|
inspectBtnLayout.flexibleHeight = 0;
|
|
|
|
|
Text inspectText = inspectBtnObj.GetComponentInChildren<Text>();
|
|
|
|
|
inspectText.text = "Inspect";
|
|
|
|
|
inspectText.color = Color.white;
|
|
|
|
|
|
|
|
|
|
Button inspectBtn = inspectBtnObj.GetComponent<Button>();
|
|
|
|
|
ColorBlock inspectColors = inspectBtn.colors;
|
2020-10-28 07:14:00 +11:00
|
|
|
|
inspectColors.normalColor = new Color(0.15f, 0.15f, 0.15f);
|
|
|
|
|
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 0.5f);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
inspectBtn.colors = inspectColors;
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#if CPP
|
2020-10-28 06:39:26 +11:00
|
|
|
|
inspectBtn.onClick.AddListener(new Action(() => { InspectorManager.Instance.Inspect(m_sceneShortList[thisIndex]); }));
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#else
|
|
|
|
|
inspectBtn.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_sceneShortList[thisIndex]); });
|
|
|
|
|
#endif
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#endregion
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
}
|