mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-06 01:23:31 +08:00
disable main menu page on failed init
This commit is contained in:
parent
25e48f2f37
commit
1a5843f8e1
@ -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";
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace UnityExplorer.UI.Main
|
||||
}
|
||||
|
||||
|
||||
public abstract void Init();
|
||||
public abstract bool Init();
|
||||
public abstract void Update();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -55,9 +55,11 @@ namespace UnityExplorer.UI.Main
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
public override bool Init()
|
||||
{
|
||||
ConstructUI();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnSceneChange()
|
||||
|
Loading…
x
Reference in New Issue
Block a user