2020-10-23 19:55:02 +11:00
|
|
|
|
using System;
|
2020-11-23 18:23:25 +11:00
|
|
|
|
using System.IO;
|
2021-01-20 17:22:36 +11:00
|
|
|
|
using System.Reflection;
|
2020-11-23 18:23:25 +11:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
using UnityExplorer.Config;
|
2021-02-26 17:54:00 +11:00
|
|
|
|
using UnityExplorer.Helpers;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
using UnityExplorer.Input;
|
2020-11-23 18:23:25 +11:00
|
|
|
|
using UnityExplorer.Inspectors;
|
2021-03-16 18:12:39 +11:00
|
|
|
|
using UnityExplorer.Runtime;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
using UnityExplorer.UI;
|
2020-11-11 20:16:43 +11:00
|
|
|
|
using UnityExplorer.UI.Modules;
|
2020-08-07 22:19:03 +10:00
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
namespace UnityExplorer
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public class ExplorerCore
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-11-13 18:46:36 +11:00
|
|
|
|
public const string NAME = "UnityExplorer";
|
2021-03-16 18:13:14 +11:00
|
|
|
|
public const string VERSION = "3.2.3";
|
2020-10-28 06:39:26 +11:00
|
|
|
|
public const string AUTHOR = "Sinai";
|
2020-11-03 20:59:13 +11:00
|
|
|
|
public const string GUID = "com.sinai.unityexplorer";
|
2021-01-02 19:38:01 +01:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
public static ExplorerCore Instance { get; private set; }
|
|
|
|
|
|
2021-03-16 18:12:39 +11:00
|
|
|
|
public static IExplorerLoader Loader =>
|
2021-01-02 19:38:01 +01:00
|
|
|
|
#if ML
|
2021-03-16 18:12:39 +11:00
|
|
|
|
ExplorerMelonMod.Instance;
|
2021-01-02 19:38:01 +01:00
|
|
|
|
#elif BIE
|
2021-03-16 18:12:39 +11:00
|
|
|
|
ExplorerBepInPlugin.Instance;
|
2021-01-20 17:22:36 +11:00
|
|
|
|
#elif STANDALONE
|
2021-03-16 18:12:39 +11:00
|
|
|
|
ExplorerStandalone.Instance;
|
2021-01-02 19:38:01 +01:00
|
|
|
|
#endif
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-16 18:12:39 +11:00
|
|
|
|
public static string EXPLORER_FOLDER => Loader.ExplorerFolder;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-09-27 22:04:23 +10:00
|
|
|
|
public ExplorerCore()
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2020-10-11 22:57:46 +11:00
|
|
|
|
if (Instance != null)
|
|
|
|
|
{
|
|
|
|
|
Log("An instance of Explorer is already active!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-07 22:19:03 +10:00
|
|
|
|
Instance = this;
|
|
|
|
|
|
2021-03-16 18:12:39 +11:00
|
|
|
|
RuntimeProvider.Init();
|
2020-11-19 16:47:18 +11:00
|
|
|
|
|
2021-03-16 18:12:39 +11:00
|
|
|
|
if (!Directory.Exists(EXPLORER_FOLDER))
|
|
|
|
|
Directory.CreateDirectory(EXPLORER_FOLDER);
|
2020-11-08 21:04:41 +11:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
ExplorerConfig.OnLoad();
|
2020-09-10 20:31:09 +10:00
|
|
|
|
|
2020-10-03 20:19:44 +10:00
|
|
|
|
InputManager.Init();
|
2020-08-27 18:05:55 +10:00
|
|
|
|
|
2021-03-16 18:12:39 +11:00
|
|
|
|
ForceUnlockCursor.Init();
|
2020-10-27 00:54:08 +11:00
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
UIManager.ShowMenu = true;
|
2020-10-08 06:15:42 +11:00
|
|
|
|
|
2020-11-13 18:46:36 +11:00
|
|
|
|
Log($"{NAME} {VERSION} initialized.");
|
2020-09-27 22:04:23 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Update()
|
2020-08-07 22:19:03 +10:00
|
|
|
|
{
|
2021-03-11 17:57:58 +11:00
|
|
|
|
UIManager.CheckUIInit();
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
if (MouseInspector.Enabled)
|
|
|
|
|
MouseInspector.UpdateInspect();
|
|
|
|
|
else
|
2021-03-11 17:57:58 +11:00
|
|
|
|
UIManager.Update();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 18:12:39 +11:00
|
|
|
|
public void OnUnityLog(string message, string stackTrace, LogType type)
|
2020-10-27 00:54:08 +11:00
|
|
|
|
{
|
|
|
|
|
if (!DebugConsole.LogUnity)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
message = $"[UNITY] {message}";
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case LogType.Assert:
|
|
|
|
|
case LogType.Log:
|
2020-11-08 21:04:41 +11:00
|
|
|
|
Log(message, true);
|
2020-10-27 00:54:08 +11:00
|
|
|
|
break;
|
|
|
|
|
case LogType.Warning:
|
2020-11-08 21:04:41 +11:00
|
|
|
|
LogWarning(message, true);
|
2020-10-27 00:54:08 +11:00
|
|
|
|
break;
|
|
|
|
|
case LogType.Exception:
|
|
|
|
|
case LogType.Error:
|
2020-11-08 21:04:41 +11:00
|
|
|
|
LogError(message, true);
|
2020-10-27 00:54:08 +11:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Log(object message, bool unity = false)
|
2020-09-27 22:04:23 +10:00
|
|
|
|
{
|
2020-10-24 20:18:42 +11:00
|
|
|
|
DebugConsole.Log(message?.ToString());
|
2020-10-27 00:54:08 +11:00
|
|
|
|
|
|
|
|
|
if (unity)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
Loader.OnLogMessage(message);
|
2020-09-27 22:04:23 +10:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 00:54:08 +11:00
|
|
|
|
public static void LogWarning(object message, bool unity = false)
|
2020-09-27 22:04:23 +10:00
|
|
|
|
{
|
2020-10-24 20:18:42 +11:00
|
|
|
|
DebugConsole.Log(message?.ToString(), "FFFF00");
|
2020-10-27 00:54:08 +11:00
|
|
|
|
|
|
|
|
|
if (unity)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
Loader.OnLogWarning(message);
|
2020-09-27 22:04:23 +10:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 00:54:08 +11:00
|
|
|
|
public static void LogError(object message, bool unity = false)
|
2020-09-27 22:04:23 +10:00
|
|
|
|
{
|
2020-10-24 20:18:42 +11:00
|
|
|
|
DebugConsole.Log(message?.ToString(), "FF0000");
|
2020-10-27 00:54:08 +11:00
|
|
|
|
|
|
|
|
|
if (unity)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-03-11 17:57:58 +11:00
|
|
|
|
Loader.OnLogError(message);
|
2020-11-12 20:31:08 +11:00
|
|
|
|
}
|
2020-08-07 22:19:03 +10:00
|
|
|
|
}
|
|
|
|
|
}
|