mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-23 08:53:05 +08:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
6aa9b3aa15 | |||
587842f46b | |||
b9c641f170 | |||
1e68529430 | |||
e84e96a63c | |||
ec8c88ab9b | |||
0eae78eeb2 | |||
a07ead2142 |
@ -20,7 +20,7 @@ namespace UnityExplorer
|
||||
public static class ExplorerCore
|
||||
{
|
||||
public const string NAME = "UnityExplorer";
|
||||
public const string VERSION = "4.3.3";
|
||||
public const string VERSION = "4.3.5";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
|
||||
|
@ -42,6 +42,11 @@ namespace UnityExplorer.ObjectExplorer
|
||||
private Dropdown sceneDropdown;
|
||||
private readonly Dictionary<Scene, Dropdown.OptionData> sceneToDropdownOption = new Dictionary<Scene, Dropdown.OptionData>();
|
||||
|
||||
// scene loader
|
||||
private Dropdown allSceneDropdown;
|
||||
private ButtonRef loadButton;
|
||||
private ButtonRef loadAdditiveButton;
|
||||
|
||||
private IEnumerable<GameObject> GetRootEntries() => SceneHandler.CurrentRootObjects;
|
||||
|
||||
public void Update()
|
||||
@ -155,7 +160,7 @@ namespace UnityExplorer.ObjectExplorer
|
||||
|
||||
private void TryLoadScene(LoadSceneMode mode, Dropdown allSceneDrop)
|
||||
{
|
||||
var text = allSceneDrop.options[allSceneDrop.value].text;
|
||||
var text = allSceneDrop.captionText.text;
|
||||
|
||||
if (text == DEFAULT_LOAD_TEXT)
|
||||
return;
|
||||
@ -250,6 +255,38 @@ namespace UnityExplorer.ObjectExplorer
|
||||
|
||||
private const string DEFAULT_LOAD_TEXT = "[Select a scene]";
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConstructSceneLoader()
|
||||
{
|
||||
// Scene Loader
|
||||
@ -259,36 +296,41 @@ namespace UnityExplorer.ObjectExplorer
|
||||
{
|
||||
var sceneLoaderObj = UIFactory.CreateVerticalGroup(m_uiRoot, "SceneLoader", true, true, true, true);
|
||||
UIFactory.SetLayoutElement(sceneLoaderObj, minHeight: 25);
|
||||
//sceneLoaderObj.SetActive(false);
|
||||
|
||||
// Title
|
||||
|
||||
var loaderTitle = UIFactory.CreateLabel(sceneLoaderObj, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14);
|
||||
UIFactory.SetLayoutElement(loaderTitle.gameObject, minHeight: 25, flexibleHeight: 0);
|
||||
|
||||
var allSceneDropObj = UIFactory.CreateDropdown(sceneLoaderObj, out Dropdown allSceneDrop, "", 14, null);
|
||||
// Search filter
|
||||
|
||||
var searchFilterObj = UIFactory.CreateInputField(sceneLoaderObj, "SearchFilterInput", "Filter scene names...");
|
||||
UIFactory.SetLayoutElement(searchFilterObj.UIRoot, minHeight: 25, flexibleHeight: 0);
|
||||
searchFilterObj.OnValueChanged += RefreshSceneLoaderOptions;
|
||||
|
||||
// Dropdown
|
||||
|
||||
var allSceneDropObj = UIFactory.CreateDropdown(sceneLoaderObj, out allSceneDropdown, "", 14, null);
|
||||
UIFactory.SetLayoutElement(allSceneDropObj, minHeight: 25, minWidth: 150, flexibleWidth: 0, flexibleHeight: 0);
|
||||
|
||||
allSceneDrop.options.Add(new Dropdown.OptionData(DEFAULT_LOAD_TEXT));
|
||||
RefreshSceneLoaderOptions(string.Empty);
|
||||
|
||||
foreach (var scene in SceneHandler.AllSceneNames)
|
||||
allSceneDrop.options.Add(new Dropdown.OptionData(Path.GetFileNameWithoutExtension(scene)));
|
||||
|
||||
allSceneDrop.value = 1;
|
||||
allSceneDrop.value = 0;
|
||||
// Button row
|
||||
|
||||
var buttonRow = UIFactory.CreateHorizontalGroup(sceneLoaderObj, "LoadButtons", true, true, true, true, 4);
|
||||
|
||||
var loadButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Single)", new Color(0.1f, 0.3f, 0.3f));
|
||||
loadButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Single)", new Color(0.1f, 0.3f, 0.3f));
|
||||
UIFactory.SetLayoutElement(loadButton.Component.gameObject, minHeight: 25, minWidth: 150);
|
||||
loadButton.OnClick += () =>
|
||||
{
|
||||
TryLoadScene(LoadSceneMode.Single, allSceneDrop);
|
||||
TryLoadScene(LoadSceneMode.Single, allSceneDropdown);
|
||||
};
|
||||
|
||||
var loadAdditiveButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Additive)", new Color(0.1f, 0.3f, 0.3f));
|
||||
loadAdditiveButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Additive)", new Color(0.1f, 0.3f, 0.3f));
|
||||
UIFactory.SetLayoutElement(loadAdditiveButton.Component.gameObject, minHeight: 25, minWidth: 150);
|
||||
loadAdditiveButton.OnClick += () =>
|
||||
{
|
||||
TryLoadScene(LoadSceneMode.Additive, allSceneDrop);
|
||||
TryLoadScene(LoadSceneMode.Additive, allSceneDropdown);
|
||||
};
|
||||
|
||||
var disabledColor = new Color(0.24f, 0.24f, 0.24f);
|
||||
@ -298,19 +340,9 @@ namespace UnityExplorer.ObjectExplorer
|
||||
loadButton.Component.interactable = false;
|
||||
loadAdditiveButton.Component.interactable = false;
|
||||
|
||||
allSceneDrop.onValueChanged.AddListener((int val) =>
|
||||
allSceneDropdown.onValueChanged.AddListener((int val) =>
|
||||
{
|
||||
var text = allSceneDrop.options[val].text;
|
||||
if (text == DEFAULT_LOAD_TEXT)
|
||||
{
|
||||
loadButton.Component.interactable = false;
|
||||
loadAdditiveButton.Component.interactable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadButton.Component.interactable = true;
|
||||
loadAdditiveButton.Component.interactable = true;
|
||||
}
|
||||
RefreshSceneLoaderButtons();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ namespace UnityExplorer.ObjectExplorer
|
||||
var scenePath = (string)method.Invoke(null, new object[] { i });
|
||||
AllSceneNames.Add(scenePath);
|
||||
}
|
||||
|
||||
WasAbleToGetScenesInBuild = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -61,8 +61,10 @@ namespace UnityExplorer.UI.Panels
|
||||
|
||||
private void SetupIO()
|
||||
{
|
||||
var fileName = $"UnityExplorer {DateTime.Now:u}.txt";
|
||||
fileName = IOUtility.EnsureValidFilename(fileName);
|
||||
var path = Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Logs");
|
||||
path = IOUtility.EnsureValidFilePath(path);
|
||||
CurrentStreamPath = IOUtility.EnsureValidFilePath(Path.Combine(path, fileName));
|
||||
|
||||
// clean old log(s)
|
||||
var files = Directory.GetFiles(path);
|
||||
@ -75,11 +77,6 @@ namespace UnityExplorer.UI.Panels
|
||||
File.Delete(files[i]);
|
||||
}
|
||||
|
||||
var fileName = $"UnityExplorer {DateTime.Now:u}.txt";
|
||||
fileName = IOUtility.EnsureValidFilename(fileName);
|
||||
|
||||
CurrentStreamPath = Path.Combine(path, fileName);
|
||||
|
||||
File.WriteAllLines(CurrentStreamPath, Logs.Select(it => it.message).ToArray());
|
||||
}
|
||||
|
||||
|
@ -446,16 +446,17 @@ namespace UnityExplorer.UI
|
||||
|
||||
AssetBundle LoadBundle(string id)
|
||||
{
|
||||
ExplorerCore.Log($"Loading {id} bundle for Unity {Application.unityVersion}");
|
||||
|
||||
return AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
|
||||
var bundle = AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
|
||||
.Assembly
|
||||
.GetManifestResourceStream($"UnityExplorer.Resources.{id}.bundle")));
|
||||
if (bundle)
|
||||
ExplorerCore.Log($"Loaded {id} bundle for Unity {Application.unityVersion}");
|
||||
return bundle;
|
||||
}
|
||||
|
||||
if (ExplorerBundle == null)
|
||||
{
|
||||
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
|
||||
ExplorerCore.LogWarning("Could not load the UnityExplorer UI Bundle!");
|
||||
DefaultFont = ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
return;
|
||||
}
|
||||
@ -505,6 +506,11 @@ namespace UnityExplorer.UI
|
||||
{
|
||||
if (TypeofAssetBundle.GetMethod("UnloadAllAssetBundles", AccessTools.all) is MethodInfo unloadAllBundles)
|
||||
{
|
||||
#if CPP
|
||||
// if IL2CPP, ensure method wasn't stripped
|
||||
if (UnhollowerBaseLib.UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(unloadAllBundles) == null)
|
||||
return;
|
||||
#endif
|
||||
var processor = ExplorerCore.Harmony.CreateProcessor(unloadAllBundles);
|
||||
var prefix = new HarmonyMethod(typeof(UIManager).GetMethod(nameof(Prefix_UnloadAllAssetBundles), AccessTools.all));
|
||||
processor.AddPrefix(prefix);
|
||||
|
Reference in New Issue
Block a user