2021-04-15 20:18:03 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
2021-04-16 17:49:05 +10:00
|
|
|
|
using System.IO;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
using UnityEngine.UI;
|
2021-06-30 07:49:58 +10:00
|
|
|
|
using UnityExplorer.UI;
|
2021-12-02 18:35:46 +11:00
|
|
|
|
using UniverseLib.UI.Models;
|
2021-05-09 20:18:33 +10:00
|
|
|
|
using UnityExplorer.UI.Panels;
|
2021-04-28 20:47:48 +10:00
|
|
|
|
using UnityExplorer.UI.Widgets;
|
2021-12-02 18:35:46 +11:00
|
|
|
|
using UniverseLib.UI;
|
|
|
|
|
using UniverseLib;
|
2021-12-28 23:24:44 +11:00
|
|
|
|
using System.Collections;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-06-30 07:49:58 +10:00
|
|
|
|
namespace UnityExplorer.ObjectExplorer
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
2021-04-23 21:50:58 +10:00
|
|
|
|
public class SceneExplorer : UIModel
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
2021-05-09 20:18:33 +10:00
|
|
|
|
public ObjectExplorerPanel Parent { get; }
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-05-09 20:18:33 +10:00
|
|
|
|
public SceneExplorer(ObjectExplorerPanel parent)
|
2021-04-23 21:50:58 +10:00
|
|
|
|
{
|
|
|
|
|
Parent = parent;
|
|
|
|
|
|
|
|
|
|
SceneHandler.OnInspectedSceneChanged += SceneHandler_OnInspectedSceneChanged;
|
|
|
|
|
SceneHandler.OnLoadedScenesChanged += SceneHandler_OnLoadedScenesChanged;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-24 17:49:34 +11:00
|
|
|
|
public override GameObject UIRoot => uiRoot;
|
|
|
|
|
private GameObject uiRoot;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-16 04:33:13 +10:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether to automatically update per auto-update interval or not.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool AutoUpdate = false;
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
public TransformTree Tree;
|
|
|
|
|
private float timeOfLastUpdate = -1f;
|
|
|
|
|
|
2021-04-16 17:49:05 +10:00
|
|
|
|
private GameObject refreshRow;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
private Dropdown sceneDropdown;
|
2021-05-27 19:30:19 +10:00
|
|
|
|
private readonly Dictionary<Scene, Dropdown.OptionData> sceneToDropdownOption = new Dictionary<Scene, Dropdown.OptionData>();
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
// scene loader
|
|
|
|
|
private Dropdown allSceneDropdown;
|
|
|
|
|
private ButtonRef loadButton;
|
|
|
|
|
private ButtonRef loadAdditiveButton;
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
private IEnumerable<GameObject> GetRootEntries() => SceneHandler.CurrentRootObjects;
|
2021-05-04 20:10:46 +10:00
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
public void Update()
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
2021-05-08 06:18:46 +10:00
|
|
|
|
if ((AutoUpdate || !SceneHandler.InspectingAssetScene) && timeOfLastUpdate.OccuredEarlierThan(1))
|
2021-04-16 04:33:13 +10:00
|
|
|
|
{
|
|
|
|
|
timeOfLastUpdate = Time.realtimeSinceStartup;
|
2021-05-03 21:02:01 +10:00
|
|
|
|
UpdateTree();
|
2021-04-16 04:33:13 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-05-03 21:02:01 +10:00
|
|
|
|
public void UpdateTree()
|
2021-04-16 04:33:13 +10:00
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
SceneHandler.Update();
|
2021-04-21 18:44:43 +10:00
|
|
|
|
Tree.RefreshData(true);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-26 17:42:31 +10:00
|
|
|
|
public void JumpToTransform(Transform transform)
|
|
|
|
|
{
|
|
|
|
|
if (!transform)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-05-26 18:32:47 +10:00
|
|
|
|
UIManager.SetPanelActive(this.Parent, true);
|
|
|
|
|
this.Parent.SetTab(0);
|
|
|
|
|
|
2021-05-26 17:42:31 +10:00
|
|
|
|
// select the transform's scene
|
|
|
|
|
var go = transform.gameObject;
|
|
|
|
|
if (SceneHandler.SelectedScene != go.scene)
|
|
|
|
|
{
|
2021-05-27 19:30:19 +10:00
|
|
|
|
int idx = sceneDropdown.options.IndexOf(sceneToDropdownOption[go.scene]);
|
2021-05-26 17:42:31 +10:00
|
|
|
|
sceneDropdown.value = idx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Let the TransformTree handle the rest
|
|
|
|
|
Tree.JumpAndExpandToTransform(transform);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
private void OnDropdownChanged(int value)
|
|
|
|
|
{
|
|
|
|
|
if (value < 0 || SceneHandler.LoadedScenes.Count <= value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
SceneHandler.SelectedScene = SceneHandler.LoadedScenes[value];
|
|
|
|
|
SceneHandler.Update();
|
|
|
|
|
Tree.RefreshData(true);
|
2021-05-04 20:10:46 +10:00
|
|
|
|
OnSelectedSceneChanged(SceneHandler.SelectedScene.Value);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SceneHandler_OnInspectedSceneChanged(Scene scene)
|
|
|
|
|
{
|
2021-05-27 19:30:19 +10:00
|
|
|
|
if (!sceneToDropdownOption.ContainsKey(scene))
|
2021-04-15 20:18:03 +10:00
|
|
|
|
PopulateSceneDropdown();
|
|
|
|
|
|
2021-05-27 19:30:19 +10:00
|
|
|
|
if (sceneToDropdownOption.ContainsKey(scene))
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
2021-05-27 19:30:19 +10:00
|
|
|
|
var opt = sceneToDropdownOption[scene];
|
2021-04-16 02:47:15 +10:00
|
|
|
|
int idx = sceneDropdown.options.IndexOf(opt);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
if (sceneDropdown.value != idx)
|
|
|
|
|
sceneDropdown.value = idx;
|
2021-04-16 02:47:15 +10:00
|
|
|
|
else
|
|
|
|
|
sceneDropdown.captionText.text = opt.text;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-05-04 20:10:46 +10:00
|
|
|
|
OnSelectedSceneChanged(scene);
|
2021-04-16 17:49:05 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-04 20:10:46 +10:00
|
|
|
|
private void OnSelectedSceneChanged(Scene scene)
|
|
|
|
|
{
|
|
|
|
|
if (refreshRow)
|
|
|
|
|
refreshRow.SetActive(!scene.IsValid());
|
|
|
|
|
}
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-07-19 21:43:36 +10:00
|
|
|
|
private void SceneHandler_OnLoadedScenesChanged(List<Scene> loadedScenes)
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
|
|
|
|
PopulateSceneDropdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PopulateSceneDropdown()
|
|
|
|
|
{
|
|
|
|
|
sceneToDropdownOption.Clear();
|
|
|
|
|
sceneDropdown.options.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var scene in SceneHandler.LoadedScenes)
|
|
|
|
|
{
|
2021-07-19 21:43:36 +10:00
|
|
|
|
if (sceneToDropdownOption.ContainsKey(scene))
|
|
|
|
|
continue;
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
string name = scene.name?.Trim();
|
|
|
|
|
|
|
|
|
|
if (!scene.IsValid())
|
|
|
|
|
name = "HideAndDontSave";
|
|
|
|
|
else if (string.IsNullOrEmpty(name))
|
|
|
|
|
name = "<untitled>";
|
|
|
|
|
|
2021-04-16 02:47:15 +10:00
|
|
|
|
var option = new Dropdown.OptionData(name);
|
|
|
|
|
sceneDropdown.options.Add(option);
|
2021-05-27 19:30:19 +10:00
|
|
|
|
sceneToDropdownOption.Add(scene, option);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnFilterInput(string input)
|
|
|
|
|
{
|
2021-05-16 21:46:38 +10:00
|
|
|
|
if ((!string.IsNullOrEmpty(input) && !Tree.Filtering) || (string.IsNullOrEmpty(input) && Tree.Filtering))
|
|
|
|
|
{
|
2021-05-26 17:42:31 +10:00
|
|
|
|
Tree.cachedTransforms.Clear();
|
2021-05-16 21:46:38 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
Tree.CurrentFilter = input;
|
2021-04-22 17:53:29 +10:00
|
|
|
|
Tree.RefreshData(true, true);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
private void TryLoadScene(LoadSceneMode mode, Dropdown allSceneDrop)
|
2021-04-16 21:07:32 +10:00
|
|
|
|
{
|
2021-10-26 15:12:52 +11:00
|
|
|
|
var text = allSceneDrop.captionText.text;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
if (text == DEFAULT_LOAD_TEXT)
|
|
|
|
|
return;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
SceneManager.LoadScene(text, mode);
|
|
|
|
|
allSceneDrop.value = 0;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.LogWarning($"Unable to load the Scene! {ex.ReflectionExToString()}");
|
|
|
|
|
}
|
2021-04-16 17:49:05 +10:00
|
|
|
|
}
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-23 21:50:58 +10:00
|
|
|
|
public override void ConstructUI(GameObject content)
|
2021-04-16 17:49:05 +10:00
|
|
|
|
{
|
2022-01-24 17:49:34 +11:00
|
|
|
|
uiRoot = UIFactory.CreateUIObject("SceneExplorer", content);
|
|
|
|
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(uiRoot, true, true, true, true, 0, 2, 2, 2, 2);
|
|
|
|
|
UIFactory.SetLayoutElement(uiRoot, flexibleHeight: 9999);
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2021-04-16 17:49:05 +10:00
|
|
|
|
// Tool bar (top area)
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2022-01-24 17:49:34 +11:00
|
|
|
|
var toolbar = UIFactory.CreateVerticalGroup(uiRoot, "Toolbar", true, true, true, true, 2, new Vector4(2, 2, 2, 2),
|
2021-04-15 20:18:03 +10:00
|
|
|
|
new Color(0.15f, 0.15f, 0.15f));
|
2021-04-16 04:33:13 +10:00
|
|
|
|
|
|
|
|
|
// Scene selector dropdown
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
var dropRow = UIFactory.CreateHorizontalGroup(toolbar, "DropdownRow", true, true, true, true, 5, default, new Color(1, 1, 1, 0));
|
|
|
|
|
UIFactory.SetLayoutElement(dropRow, minHeight: 25, flexibleWidth: 9999);
|
|
|
|
|
|
|
|
|
|
var dropLabel = UIFactory.CreateLabel(dropRow, "SelectorLabel", "Scene:", TextAnchor.MiddleLeft, Color.cyan, false, 15);
|
|
|
|
|
UIFactory.SetLayoutElement(dropLabel.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0);
|
|
|
|
|
|
|
|
|
|
var dropdownObj = UIFactory.CreateDropdown(dropRow, out sceneDropdown, "<notset>", 13, OnDropdownChanged);
|
|
|
|
|
UIFactory.SetLayoutElement(dropdownObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
|
|
|
|
SceneHandler.Update();
|
|
|
|
|
PopulateSceneDropdown();
|
2021-04-16 02:47:15 +10:00
|
|
|
|
sceneDropdown.captionText.text = sceneToDropdownOption.First().Value.text;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-16 04:33:13 +10:00
|
|
|
|
// Filter row
|
|
|
|
|
|
|
|
|
|
var filterRow = UIFactory.CreateHorizontalGroup(toolbar, "FilterGroup", true, true, true, true, 2, new Vector4(2, 2, 2, 2));
|
|
|
|
|
UIFactory.SetLayoutElement(filterRow, minHeight: 25, flexibleHeight: 0);
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
//Filter input field
|
2021-12-24 15:17:48 +11:00
|
|
|
|
var inputField = UIFactory.CreateInputField(filterRow, "FilterInput", "Search and press enter...");
|
2021-05-11 19:18:27 +10:00
|
|
|
|
inputField.Component.targetGraphic.color = new Color(0.2f, 0.2f, 0.2f);
|
2021-06-05 19:36:09 +10:00
|
|
|
|
RuntimeProvider.Instance.SetColorBlock(inputField.Component, new Color(0.4f, 0.4f, 0.4f), new Color(0.2f, 0.2f, 0.2f),
|
2021-05-07 17:06:56 +10:00
|
|
|
|
new Color(0.08f, 0.08f, 0.08f));
|
|
|
|
|
UIFactory.SetLayoutElement(inputField.UIRoot, minHeight: 25);
|
2021-12-24 15:17:48 +11:00
|
|
|
|
//inputField.OnValueChanged += OnFilterInput;
|
|
|
|
|
inputField.Component.GetOnEndEdit().AddListener(OnFilterInput);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-16 17:49:05 +10:00
|
|
|
|
// refresh row
|
|
|
|
|
|
|
|
|
|
refreshRow = UIFactory.CreateHorizontalGroup(toolbar, "RefreshGroup", true, true, true, true, 2, new Vector4(2, 2, 2, 2));
|
|
|
|
|
UIFactory.SetLayoutElement(refreshRow, minHeight: 30, flexibleHeight: 0);
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
var refreshButton = UIFactory.CreateButton(refreshRow, "RefreshButton", "Update");
|
2021-05-11 19:18:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(refreshButton.Component.gameObject, minWidth: 65, flexibleWidth: 0);
|
2021-05-03 21:02:01 +10:00
|
|
|
|
refreshButton.OnClick += UpdateTree;
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
|
|
|
|
var refreshToggle = UIFactory.CreateToggle(refreshRow, "RefreshToggle", out Toggle toggle, out Text text);
|
|
|
|
|
UIFactory.SetLayoutElement(refreshToggle, flexibleWidth: 9999);
|
|
|
|
|
text.text = "Auto-update (1 second)";
|
|
|
|
|
text.alignment = TextAnchor.MiddleLeft;
|
|
|
|
|
text.color = Color.white;
|
|
|
|
|
text.fontSize = 12;
|
|
|
|
|
toggle.isOn = false;
|
|
|
|
|
toggle.onValueChanged.AddListener((bool val) => AutoUpdate = val);
|
|
|
|
|
|
2021-05-05 21:27:09 +10:00
|
|
|
|
refreshRow.SetActive(false);
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
// Transform Tree
|
2021-04-23 21:50:58 +10:00
|
|
|
|
|
2022-01-24 17:49:34 +11:00
|
|
|
|
var scrollPool = UIFactory.CreateScrollPool<TransformCell>(uiRoot, "TransformTree", out GameObject scrollObj,
|
2021-04-26 19:56:21 +10:00
|
|
|
|
out GameObject scrollContent, new Color(0.11f, 0.11f, 0.11f));
|
2021-04-16 02:47:15 +10:00
|
|
|
|
UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
UIFactory.SetLayoutElement(scrollContent, flexibleHeight: 9999);
|
|
|
|
|
|
2021-05-16 21:46:38 +10:00
|
|
|
|
Tree = new TransformTree(scrollPool, GetRootEntries);
|
2021-04-16 02:47:15 +10:00
|
|
|
|
Tree.Init();
|
2021-04-26 19:56:21 +10:00
|
|
|
|
Tree.RefreshData(true, true);
|
2021-04-22 17:53:29 +10:00
|
|
|
|
//scrollPool.Viewport.GetComponent<Mask>().enabled = false;
|
|
|
|
|
//UIRoot.GetComponent<Mask>().enabled = false;
|
|
|
|
|
|
2021-04-21 23:07:15 +10:00
|
|
|
|
// Scene Loader
|
|
|
|
|
|
|
|
|
|
ConstructSceneLoader();
|
2021-12-28 23:24:44 +11:00
|
|
|
|
|
|
|
|
|
RuntimeProvider.Instance.StartCoroutine(TempFixCoro());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// To "fix" a strange FPS drop issue with MelonLoader.
|
|
|
|
|
private IEnumerator TempFixCoro()
|
|
|
|
|
{
|
|
|
|
|
float start = Time.realtimeSinceStartup;
|
|
|
|
|
|
|
|
|
|
while (Time.realtimeSinceStartup - start < 2.5f)
|
|
|
|
|
yield return null;
|
|
|
|
|
|
|
|
|
|
// Select "HideAndDontSave" and then go back to first scene.
|
|
|
|
|
this.sceneDropdown.value = sceneDropdown.options.Count - 1;
|
|
|
|
|
this.sceneDropdown.value = 0;
|
2021-04-21 23:07:15 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private const string DEFAULT_LOAD_TEXT = "[Select a scene]";
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
private void RefreshSceneLoaderOptions(string filter)
|
|
|
|
|
{
|
|
|
|
|
allSceneDropdown.options.Clear();
|
|
|
|
|
allSceneDropdown.options.Add(new Dropdown.OptionData(DEFAULT_LOAD_TEXT));
|
|
|
|
|
|
|
|
|
|
foreach (var scene in SceneHandler.AllSceneNames)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(filter) || scene.ContainsIgnoreCase(filter))
|
|
|
|
|
allSceneDropdown.options.Add(new Dropdown.OptionData(Path.GetFileNameWithoutExtension(scene)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allSceneDropdown.RefreshShownValue();
|
|
|
|
|
|
|
|
|
|
if (loadButton != null)
|
|
|
|
|
RefreshSceneLoaderButtons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshSceneLoaderButtons()
|
|
|
|
|
{
|
|
|
|
|
var text = allSceneDropdown.captionText.text;
|
|
|
|
|
if (text == DEFAULT_LOAD_TEXT)
|
|
|
|
|
{
|
|
|
|
|
loadButton.Component.interactable = false;
|
|
|
|
|
loadAdditiveButton.Component.interactable = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
loadButton.Component.interactable = true;
|
|
|
|
|
loadAdditiveButton.Component.interactable = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-21 23:07:15 +10:00
|
|
|
|
private void ConstructSceneLoader()
|
|
|
|
|
{
|
2021-04-16 17:49:05 +10:00
|
|
|
|
// Scene Loader
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-16 18:37:26 +10:00
|
|
|
|
if (SceneHandler.WasAbleToGetScenesInBuild)
|
|
|
|
|
{
|
2022-01-24 17:49:34 +11:00
|
|
|
|
var sceneLoaderObj = UIFactory.CreateVerticalGroup(uiRoot, "SceneLoader", true, true, true, true);
|
2021-04-21 18:44:43 +10:00
|
|
|
|
UIFactory.SetLayoutElement(sceneLoaderObj, minHeight: 25);
|
2021-10-26 15:12:52 +11:00
|
|
|
|
|
|
|
|
|
// Title
|
2021-04-21 18:44:43 +10:00
|
|
|
|
|
|
|
|
|
var loaderTitle = UIFactory.CreateLabel(sceneLoaderObj, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14);
|
2021-04-16 18:37:26 +10:00
|
|
|
|
UIFactory.SetLayoutElement(loaderTitle.gameObject, minHeight: 25, flexibleHeight: 0);
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
// Search filter
|
|
|
|
|
|
|
|
|
|
var searchFilterObj = UIFactory.CreateInputField(sceneLoaderObj, "SearchFilterInput", "Filter scene names...");
|
|
|
|
|
UIFactory.SetLayoutElement(searchFilterObj.UIRoot, minHeight: 25, flexibleHeight: 0);
|
|
|
|
|
searchFilterObj.OnValueChanged += RefreshSceneLoaderOptions;
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
// Dropdown
|
|
|
|
|
|
|
|
|
|
var allSceneDropObj = UIFactory.CreateDropdown(sceneLoaderObj, out allSceneDropdown, "", 14, null);
|
|
|
|
|
UIFactory.SetLayoutElement(allSceneDropObj, minHeight: 25, minWidth: 150, flexibleWidth: 0, flexibleHeight: 0);
|
2021-04-21 18:44:43 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
RefreshSceneLoaderOptions(string.Empty);
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
// Button row
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-04-21 18:44:43 +10:00
|
|
|
|
var buttonRow = UIFactory.CreateHorizontalGroup(sceneLoaderObj, "LoadButtons", true, true, true, true, 4);
|
2021-04-16 17:49:05 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
loadButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Single)", new Color(0.1f, 0.3f, 0.3f));
|
2021-05-11 19:18:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(loadButton.Component.gameObject, minHeight: 25, minWidth: 150);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
loadButton.OnClick += () =>
|
2021-04-16 17:49:05 +10:00
|
|
|
|
{
|
2021-10-26 15:12:52 +11:00
|
|
|
|
TryLoadScene(LoadSceneMode.Single, allSceneDropdown);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
};
|
2021-04-16 18:37:26 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
loadAdditiveButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Additive)", new Color(0.1f, 0.3f, 0.3f));
|
2021-05-11 19:18:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(loadAdditiveButton.Component.gameObject, minHeight: 25, minWidth: 150);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
loadAdditiveButton.OnClick += () =>
|
2021-04-16 17:49:05 +10:00
|
|
|
|
{
|
2021-10-26 15:12:52 +11:00
|
|
|
|
TryLoadScene(LoadSceneMode.Additive, allSceneDropdown);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
};
|
2021-04-21 23:07:15 +10:00
|
|
|
|
|
|
|
|
|
var disabledColor = new Color(0.24f, 0.24f, 0.24f);
|
2021-05-11 19:18:27 +10:00
|
|
|
|
RuntimeProvider.Instance.SetColorBlock(loadButton.Component, disabled: disabledColor);
|
|
|
|
|
RuntimeProvider.Instance.SetColorBlock(loadAdditiveButton.Component, disabled: disabledColor);
|
2021-04-21 23:07:15 +10:00
|
|
|
|
|
2021-05-11 19:18:27 +10:00
|
|
|
|
loadButton.Component.interactable = false;
|
|
|
|
|
loadAdditiveButton.Component.interactable = false;
|
2021-04-21 23:07:15 +10:00
|
|
|
|
|
2021-10-26 15:12:52 +11:00
|
|
|
|
allSceneDropdown.onValueChanged.AddListener((int val) =>
|
2021-04-21 23:07:15 +10:00
|
|
|
|
{
|
2021-10-26 15:12:52 +11:00
|
|
|
|
RefreshSceneLoaderButtons();
|
2021-04-21 23:07:15 +10:00
|
|
|
|
});
|
2021-04-16 18:37:26 +10:00
|
|
|
|
}
|
2021-04-16 17:49:05 +10:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.LogWarning($"Could not create the Scene Loader helper! {ex.ReflectionExToString()}");
|
|
|
|
|
}
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|