Compare commits

...

5 Commits
4.3.4 ... 4.3.5

Author SHA1 Message Date
6aa9b3aa15 Bump version 2021-10-26 15:12:56 +11:00
587842f46b Add search filter to scene loader dropdown 2021-10-26 15:12:52 +11:00
b9c641f170 Fix scene loader not showing 2021-10-26 15:12:44 +11:00
1e68529430 Don't patch stripped UnloadAllAssetBundles 2021-10-22 15:54:14 +11:00
e84e96a63c Bump version 2021-10-21 20:04:48 +11:00
4 changed files with 70 additions and 30 deletions

View File

@ -20,7 +20,7 @@ namespace UnityExplorer
public static class ExplorerCore public static class ExplorerCore
{ {
public const string NAME = "UnityExplorer"; 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 AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer"; public const string GUID = "com.sinai.unityexplorer";

View File

@ -42,6 +42,11 @@ namespace UnityExplorer.ObjectExplorer
private Dropdown sceneDropdown; private Dropdown sceneDropdown;
private readonly Dictionary<Scene, Dropdown.OptionData> sceneToDropdownOption = new Dictionary<Scene, Dropdown.OptionData>(); 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; private IEnumerable<GameObject> GetRootEntries() => SceneHandler.CurrentRootObjects;
public void Update() public void Update()
@ -155,7 +160,7 @@ namespace UnityExplorer.ObjectExplorer
private void TryLoadScene(LoadSceneMode mode, Dropdown allSceneDrop) private void TryLoadScene(LoadSceneMode mode, Dropdown allSceneDrop)
{ {
var text = allSceneDrop.options[allSceneDrop.value].text; var text = allSceneDrop.captionText.text;
if (text == DEFAULT_LOAD_TEXT) if (text == DEFAULT_LOAD_TEXT)
return; return;
@ -250,6 +255,38 @@ namespace UnityExplorer.ObjectExplorer
private const string DEFAULT_LOAD_TEXT = "[Select a scene]"; 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() private void ConstructSceneLoader()
{ {
// Scene Loader // Scene Loader
@ -259,36 +296,41 @@ namespace UnityExplorer.ObjectExplorer
{ {
var sceneLoaderObj = UIFactory.CreateVerticalGroup(m_uiRoot, "SceneLoader", true, true, true, true); var sceneLoaderObj = UIFactory.CreateVerticalGroup(m_uiRoot, "SceneLoader", true, true, true, true);
UIFactory.SetLayoutElement(sceneLoaderObj, minHeight: 25); UIFactory.SetLayoutElement(sceneLoaderObj, minHeight: 25);
//sceneLoaderObj.SetActive(false);
// Title
var loaderTitle = UIFactory.CreateLabel(sceneLoaderObj, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14); var loaderTitle = UIFactory.CreateLabel(sceneLoaderObj, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14);
UIFactory.SetLayoutElement(loaderTitle.gameObject, minHeight: 25, flexibleHeight: 0); 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); 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) // Button row
allSceneDrop.options.Add(new Dropdown.OptionData(Path.GetFileNameWithoutExtension(scene)));
allSceneDrop.value = 1;
allSceneDrop.value = 0;
var buttonRow = UIFactory.CreateHorizontalGroup(sceneLoaderObj, "LoadButtons", true, true, true, true, 4); 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); UIFactory.SetLayoutElement(loadButton.Component.gameObject, minHeight: 25, minWidth: 150);
loadButton.OnClick += () => 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); UIFactory.SetLayoutElement(loadAdditiveButton.Component.gameObject, minHeight: 25, minWidth: 150);
loadAdditiveButton.OnClick += () => loadAdditiveButton.OnClick += () =>
{ {
TryLoadScene(LoadSceneMode.Additive, allSceneDrop); TryLoadScene(LoadSceneMode.Additive, allSceneDropdown);
}; };
var disabledColor = new Color(0.24f, 0.24f, 0.24f); var disabledColor = new Color(0.24f, 0.24f, 0.24f);
@ -298,19 +340,9 @@ namespace UnityExplorer.ObjectExplorer
loadButton.Component.interactable = false; loadButton.Component.interactable = false;
loadAdditiveButton.Component.interactable = false; loadAdditiveButton.Component.interactable = false;
allSceneDrop.onValueChanged.AddListener((int val) => allSceneDropdown.onValueChanged.AddListener((int val) =>
{ {
var text = allSceneDrop.options[val].text; RefreshSceneLoaderButtons();
if (text == DEFAULT_LOAD_TEXT)
{
loadButton.Component.interactable = false;
loadAdditiveButton.Component.interactable = false;
}
else
{
loadButton.Component.interactable = true;
loadAdditiveButton.Component.interactable = true;
}
}); });
} }
} }

View File

@ -97,6 +97,8 @@ namespace UnityExplorer.ObjectExplorer
var scenePath = (string)method.Invoke(null, new object[] { i }); var scenePath = (string)method.Invoke(null, new object[] { i });
AllSceneNames.Add(scenePath); AllSceneNames.Add(scenePath);
} }
WasAbleToGetScenesInBuild = true;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -446,16 +446,17 @@ namespace UnityExplorer.UI
AssetBundle LoadBundle(string id) AssetBundle LoadBundle(string id)
{ {
ExplorerCore.Log($"Loading {id} bundle for Unity {Application.unityVersion}"); var bundle = AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
return AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
.Assembly .Assembly
.GetManifestResourceStream($"UnityExplorer.Resources.{id}.bundle"))); .GetManifestResourceStream($"UnityExplorer.Resources.{id}.bundle")));
if (bundle)
ExplorerCore.Log($"Loaded {id} bundle for Unity {Application.unityVersion}");
return bundle;
} }
if (ExplorerBundle == null) 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"); DefaultFont = ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
return; return;
} }
@ -505,6 +506,11 @@ namespace UnityExplorer.UI
{ {
if (TypeofAssetBundle.GetMethod("UnloadAllAssetBundles", AccessTools.all) is MethodInfo unloadAllBundles) 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 processor = ExplorerCore.Harmony.CreateProcessor(unloadAllBundles);
var prefix = new HarmonyMethod(typeof(UIManager).GetMethod(nameof(Prefix_UnloadAllAssetBundles), AccessTools.all)); var prefix = new HarmonyMethod(typeof(UIManager).GetMethod(nameof(Prefix_UnloadAllAssetBundles), AccessTools.all));
processor.AddPrefix(prefix); processor.AddPrefix(prefix);