diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 4b5df91..c8b1638 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -17,7 +17,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.2.3"; + public const string VERSION = "3.2.4"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/UI/Main/BaseMenuPage.cs b/src/UI/Main/BaseMenuPage.cs index b80c769..7f23fef 100644 --- a/src/UI/Main/BaseMenuPage.cs +++ b/src/UI/Main/BaseMenuPage.cs @@ -21,7 +21,7 @@ namespace UnityExplorer.UI.Main } - public abstract void Init(); + public abstract bool Init(); public abstract void Update(); } } diff --git a/src/UI/Main/CSConsole/CSharpConsole.cs b/src/UI/Main/CSConsole/CSharpConsole.cs index 335c562..c2c24ff 100644 --- a/src/UI/Main/CSConsole/CSharpConsole.cs +++ b/src/UI/Main/CSConsole/CSharpConsole.cs @@ -12,6 +12,7 @@ using UnityEngine.EventSystems; using UnityEngine.UI; using UnityExplorer.UI.Reusable; using UnityExplorer.UI.Main.CSConsole; +using UnityExplorer.Core; namespace UnityExplorer.UI.Main { @@ -40,13 +41,12 @@ namespace UnityExplorer.UI.Main #endif }; - public override void Init() + public override bool Init() { Instance = this; try { - //m_codeEditor = new UI.CSConsole.CSharpConsole(); InitConsole(); AutoCompleter.Init(); @@ -57,14 +57,21 @@ namespace UnityExplorer.UI.Main m_evaluator.Compile(""); foreach (string use in DefaultUsing) - { AddUsing(use); - } + + return true; } catch (Exception e) { - ExplorerCore.LogWarning($"Error setting up console!\r\nMessage: {e.Message}"); - MainMenu.Instance.Pages.RemoveAll(it => it is CSharpConsole); + string info = "The C# Console has been disabled because"; + if (e is NotSupportedException && e.TargetSite?.Name == "DefineDynamicAssembly") + info += " Reflection.Emit is not supported."; + else + info += $" of an unknown error.\r\n({e.ReflectionExToString()})"; + + ExplorerCore.LogWarning(info); + + return false; } } diff --git a/src/UI/Main/Home/HomePage.cs b/src/UI/Main/Home/HomePage.cs index 140c562..a6aeb42 100644 --- a/src/UI/Main/Home/HomePage.cs +++ b/src/UI/Main/Home/HomePage.cs @@ -13,7 +13,7 @@ namespace UnityExplorer.UI.Main public static HomePage Instance { get; internal set; } - public override void Init() + public override bool Init() { Instance = this; @@ -24,6 +24,8 @@ namespace UnityExplorer.UI.Main new InspectorManager(); SceneExplorer.Instance.Init(); + + return true; } public override void Update() diff --git a/src/UI/Main/MainMenu.cs b/src/UI/Main/MainMenu.cs index d63659c..8e0fd14 100644 --- a/src/UI/Main/MainMenu.cs +++ b/src/UI/Main/MainMenu.cs @@ -49,10 +49,19 @@ namespace UnityExplorer.UI.Main for (int i = 0; i < Pages.Count; i++) { var page = Pages[i]; - page.Init(); - - if (!Pages.Contains(page)) + + if (!page.Init()) + { + // page init failed. + Pages.RemoveAt(i); i--; + + if (page.RefNavbarButton) + page.RefNavbarButton.interactable = false; + + if (page.Content) + GameObject.Destroy(page.Content); + } } // hide menu until each page has init layout (bit of a hack) diff --git a/src/UI/Main/Options/OptionsPage.cs b/src/UI/Main/Options/OptionsPage.cs index f2d0a89..ec0c14f 100644 --- a/src/UI/Main/Options/OptionsPage.cs +++ b/src/UI/Main/Options/OptionsPage.cs @@ -18,9 +18,11 @@ namespace UnityExplorer.UI.Main private InputField m_defaultOutputInput; private Toggle m_hideOnStartupToggle; - public override void Init() + public override bool Init() { ConstructUI(); + + return true; } public override void Update() diff --git a/src/UI/Main/Search/SearchPage.cs b/src/UI/Main/Search/SearchPage.cs index b8d41eb..75b4a0b 100644 --- a/src/UI/Main/Search/SearchPage.cs +++ b/src/UI/Main/Search/SearchPage.cs @@ -55,9 +55,11 @@ namespace UnityExplorer.UI.Main Instance = this; } - public override void Init() + public override bool Init() { ConstructUI(); + + return true; } public void OnSceneChange()