mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-08 18:43:37 +08:00
cleanup scene loader, redundant code
This commit is contained in:
parent
480a8cb31c
commit
40d32e1919
@ -13,7 +13,7 @@ namespace UnityExplorer
|
|||||||
public class ExplorerCore
|
public class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "3.3.12";
|
public const string VERSION = "3.4.0";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
@ -248,23 +248,17 @@ namespace UnityExplorer.UI.Panels
|
|||||||
// Scene Loader
|
// Scene Loader
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Type sceneUtil = ReflectionUtility.GetTypeByName("UnityEngine.SceneManagement.SceneUtility");
|
if (SceneHandler.WasAbleToGetScenesInBuild)
|
||||||
if (sceneUtil == null)
|
{
|
||||||
throw new Exception("This version of Unity does not ship with the 'SceneUtility' class, or it was not unstripped.");
|
var loaderTitle = UIFactory.CreateLabel(content, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14);
|
||||||
var method = sceneUtil.GetMethod("GetScenePathByBuildIndex", ReflectionUtility.AllFlags);
|
UIFactory.SetLayoutElement(loaderTitle.gameObject, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
var title2 = UIFactory.CreateLabel(content, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14);
|
|
||||||
UIFactory.SetLayoutElement(title2.gameObject, minHeight: 25, flexibleHeight: 0);
|
|
||||||
|
|
||||||
var allSceneDropObj = UIFactory.CreateDropdown(content, out Dropdown allSceneDrop, "", 14, null);
|
var allSceneDropObj = UIFactory.CreateDropdown(content, out Dropdown allSceneDrop, "", 14, null);
|
||||||
UIFactory.SetLayoutElement(allSceneDropObj, minHeight: 25, minWidth: 150, flexibleWidth: 0, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(allSceneDropObj, minHeight: 25, minWidth: 150, flexibleWidth: 0, flexibleHeight: 0);
|
||||||
|
|
||||||
int sceneCount = SceneManager.sceneCountInBuildSettings;
|
foreach (var scene in SceneHandler.AllSceneNames)
|
||||||
for (int i = 0; i < sceneCount; i++)
|
allSceneDrop.options.Add(new Dropdown.OptionData(scene));
|
||||||
{
|
|
||||||
var scenePath = (string)method.Invoke(null, new object[] { i });
|
|
||||||
allSceneDrop.options.Add(new Dropdown.OptionData(Path.GetFileNameWithoutExtension(scenePath)));
|
|
||||||
}
|
|
||||||
allSceneDrop.value = 1;
|
allSceneDrop.value = 1;
|
||||||
allSceneDrop.value = 0;
|
allSceneDrop.value = 0;
|
||||||
|
|
||||||
@ -296,6 +290,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
}, new Color(0.1f, 0.3f, 0.3f));
|
}, new Color(0.1f, 0.3f, 0.3f));
|
||||||
UIFactory.SetLayoutElement(loadAdditiveButton.gameObject, minHeight: 25, minWidth: 150);
|
UIFactory.SetLayoutElement(loadAdditiveButton.gameObject, minHeight: 25, minWidth: 150);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning($"Could not create the Scene Loader helper! {ex.ReflectionExToString()}");
|
ExplorerCore.LogWarning($"Could not create the Scene Loader helper! {ex.ReflectionExToString()}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user