Compare commits

...

8 Commits
4.3.3 ... 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
ec8c88ab9b Actually fix Logs folder 2021-10-19 16:34:46 +11:00
0eae78eeb2 Update LogPanel.cs 2021-10-19 16:32:33 +11:00
a07ead2142 Fix log folder not being created 2021-10-19 04:30:35 +11:00
5 changed files with 73 additions and 36 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,57 +255,26 @@ namespace UnityExplorer.ObjectExplorer
private const string DEFAULT_LOAD_TEXT = "[Select a scene]"; private const string DEFAULT_LOAD_TEXT = "[Select a scene]";
private void ConstructSceneLoader() private void RefreshSceneLoaderOptions(string filter)
{ {
// Scene Loader allSceneDropdown.options.Clear();
try allSceneDropdown.options.Add(new Dropdown.OptionData(DEFAULT_LOAD_TEXT));
{
if (SceneHandler.WasAbleToGetScenesInBuild)
{
var sceneLoaderObj = UIFactory.CreateVerticalGroup(m_uiRoot, "SceneLoader", true, true, true, true);
UIFactory.SetLayoutElement(sceneLoaderObj, minHeight: 25);
//sceneLoaderObj.SetActive(false);
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);
UIFactory.SetLayoutElement(allSceneDropObj, minHeight: 25, minWidth: 150, flexibleWidth: 0, flexibleHeight: 0);
allSceneDrop.options.Add(new Dropdown.OptionData(DEFAULT_LOAD_TEXT));
foreach (var scene in SceneHandler.AllSceneNames) foreach (var scene in SceneHandler.AllSceneNames)
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 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); if (string.IsNullOrEmpty(filter) || scene.ContainsIgnoreCase(filter))
}; allSceneDropdown.options.Add(new Dropdown.OptionData(Path.GetFileNameWithoutExtension(scene)));
}
var loadAdditiveButton = UIFactory.CreateButton(buttonRow, "LoadSceneButton", "Load (Additive)", new Color(0.1f, 0.3f, 0.3f)); allSceneDropdown.RefreshShownValue();
UIFactory.SetLayoutElement(loadAdditiveButton.Component.gameObject, minHeight: 25, minWidth: 150);
loadAdditiveButton.OnClick += () => if (loadButton != null)
RefreshSceneLoaderButtons();
}
private void RefreshSceneLoaderButtons()
{ {
TryLoadScene(LoadSceneMode.Additive, allSceneDrop); var text = allSceneDropdown.captionText.text;
};
var disabledColor = new Color(0.24f, 0.24f, 0.24f);
RuntimeProvider.Instance.SetColorBlock(loadButton.Component, disabled: disabledColor);
RuntimeProvider.Instance.SetColorBlock(loadAdditiveButton.Component, disabled: disabledColor);
loadButton.Component.interactable = false;
loadAdditiveButton.Component.interactable = false;
allSceneDrop.onValueChanged.AddListener((int val) =>
{
var text = allSceneDrop.options[val].text;
if (text == DEFAULT_LOAD_TEXT) if (text == DEFAULT_LOAD_TEXT)
{ {
loadButton.Component.interactable = false; loadButton.Component.interactable = false;
@ -311,6 +285,64 @@ namespace UnityExplorer.ObjectExplorer
loadButton.Component.interactable = true; loadButton.Component.interactable = true;
loadAdditiveButton.Component.interactable = true; loadAdditiveButton.Component.interactable = true;
} }
}
private void ConstructSceneLoader()
{
// Scene Loader
try
{
if (SceneHandler.WasAbleToGetScenesInBuild)
{
var sceneLoaderObj = UIFactory.CreateVerticalGroup(m_uiRoot, "SceneLoader", true, true, true, true);
UIFactory.SetLayoutElement(sceneLoaderObj, minHeight: 25);
// Title
var loaderTitle = UIFactory.CreateLabel(sceneLoaderObj, "SceneLoaderLabel", "Scene Loader", TextAnchor.MiddleLeft, Color.white, true, 14);
UIFactory.SetLayoutElement(loaderTitle.gameObject, minHeight: 25, flexibleHeight: 0);
// 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);
RefreshSceneLoaderOptions(string.Empty);
// Button row
var buttonRow = UIFactory.CreateHorizontalGroup(sceneLoaderObj, "LoadButtons", true, true, true, true, 4);
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, allSceneDropdown);
};
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, allSceneDropdown);
};
var disabledColor = new Color(0.24f, 0.24f, 0.24f);
RuntimeProvider.Instance.SetColorBlock(loadButton.Component, disabled: disabledColor);
RuntimeProvider.Instance.SetColorBlock(loadAdditiveButton.Component, disabled: disabledColor);
loadButton.Component.interactable = false;
loadAdditiveButton.Component.interactable = false;
allSceneDropdown.onValueChanged.AddListener((int val) =>
{
RefreshSceneLoaderButtons();
}); });
} }
} }

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

@ -61,8 +61,10 @@ namespace UnityExplorer.UI.Panels
private void SetupIO() private void SetupIO()
{ {
var fileName = $"UnityExplorer {DateTime.Now:u}.txt";
fileName = IOUtility.EnsureValidFilename(fileName);
var path = Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Logs"); var path = Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Logs");
path = IOUtility.EnsureValidFilePath(path); CurrentStreamPath = IOUtility.EnsureValidFilePath(Path.Combine(path, fileName));
// clean old log(s) // clean old log(s)
var files = Directory.GetFiles(path); var files = Directory.GetFiles(path);
@ -75,11 +77,6 @@ namespace UnityExplorer.UI.Panels
File.Delete(files[i]); 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()); File.WriteAllLines(CurrentStreamPath, Logs.Select(it => it.message).ToArray());
} }

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);