mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +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 class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
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 AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
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();
|
public abstract void Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using UnityEngine.EventSystems;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.Reusable;
|
using UnityExplorer.UI.Reusable;
|
||||||
using UnityExplorer.UI.Main.CSConsole;
|
using UnityExplorer.UI.Main.CSConsole;
|
||||||
|
using UnityExplorer.Core;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Main
|
namespace UnityExplorer.UI.Main
|
||||||
{
|
{
|
||||||
@ -40,13 +41,12 @@ namespace UnityExplorer.UI.Main
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
public override void Init()
|
public override bool Init()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//m_codeEditor = new UI.CSConsole.CSharpConsole();
|
|
||||||
InitConsole();
|
InitConsole();
|
||||||
|
|
||||||
AutoCompleter.Init();
|
AutoCompleter.Init();
|
||||||
@ -57,14 +57,21 @@ namespace UnityExplorer.UI.Main
|
|||||||
m_evaluator.Compile("");
|
m_evaluator.Compile("");
|
||||||
|
|
||||||
foreach (string use in DefaultUsing)
|
foreach (string use in DefaultUsing)
|
||||||
{
|
|
||||||
AddUsing(use);
|
AddUsing(use);
|
||||||
}
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning($"Error setting up console!\r\nMessage: {e.Message}");
|
string info = "The C# Console has been disabled because";
|
||||||
MainMenu.Instance.Pages.RemoveAll(it => it is CSharpConsole);
|
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 static HomePage Instance { get; internal set; }
|
||||||
|
|
||||||
public override void Init()
|
public override bool Init()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
@ -24,6 +24,8 @@ namespace UnityExplorer.UI.Main
|
|||||||
new InspectorManager();
|
new InspectorManager();
|
||||||
|
|
||||||
SceneExplorer.Instance.Init();
|
SceneExplorer.Instance.Init();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
|
@ -49,10 +49,19 @@ namespace UnityExplorer.UI.Main
|
|||||||
for (int i = 0; i < Pages.Count; i++)
|
for (int i = 0; i < Pages.Count; i++)
|
||||||
{
|
{
|
||||||
var page = Pages[i];
|
var page = Pages[i];
|
||||||
page.Init();
|
|
||||||
|
if (!page.Init())
|
||||||
if (!Pages.Contains(page))
|
{
|
||||||
|
// page init failed.
|
||||||
|
Pages.RemoveAt(i);
|
||||||
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)
|
// 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 InputField m_defaultOutputInput;
|
||||||
private Toggle m_hideOnStartupToggle;
|
private Toggle m_hideOnStartupToggle;
|
||||||
|
|
||||||
public override void Init()
|
public override bool Init()
|
||||||
{
|
{
|
||||||
ConstructUI();
|
ConstructUI();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
|
@ -55,9 +55,11 @@ namespace UnityExplorer.UI.Main
|
|||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Init()
|
public override bool Init()
|
||||||
{
|
{
|
||||||
ConstructUI();
|
ConstructUI();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSceneChange()
|
public void OnSceneChange()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user