mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
Add support for Unity Editor release
This commit is contained in:
parent
efdf2446bd
commit
2285a495be
@ -51,6 +51,12 @@ The standalone release can be used with any injector or loader of your choice, b
|
||||
3. Create an instance of Unity Explorer with `UnityExplorer.ExplorerStandalone.CreateInstance();`
|
||||
4. Optionally subscribe to the `ExplorerStandalone.OnLog` event to handle logging if you wish
|
||||
|
||||
## Unity Editor
|
||||
|
||||
1. Download the [`UnityExplorer.Editor`](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Editor.zip) release.
|
||||
2. Install the package, either by using the Package Manager and importing the `package.json` file, or by manually dragging the folder into your `Assets` folder.
|
||||
3. Drag the `Runtime/UnityExplorer` prefab into your scene, or create a GameObject and add the `Explorer Editor Behaviour` script to it.
|
||||
|
||||
# Common issues and solutions
|
||||
|
||||
Although UnityExplorer should work out of the box for most Unity games, in some cases you may need to tweak the settings for it to work properly.
|
||||
|
33
src/Loader/Standalone/Editor/ExplorerEditorBehaviour.cs
Normal file
33
src/Loader/Standalone/Editor/ExplorerEditorBehaviour.cs
Normal file
@ -0,0 +1,33 @@
|
||||
#if STANDALONE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityExplorer.Loader.Standalone
|
||||
{
|
||||
public class ExplorerEditorBehaviour : MonoBehaviour
|
||||
{
|
||||
internal void Awake()
|
||||
{
|
||||
ExplorerEditorLoader.Initialize();
|
||||
DontDestroyOnLoad(this);
|
||||
this.gameObject.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
|
||||
internal void OnDestroy()
|
||||
{
|
||||
OnApplicationQuit();
|
||||
}
|
||||
|
||||
internal void OnApplicationQuit()
|
||||
{
|
||||
if (UI.UIManager.UIRoot)
|
||||
Destroy(UI.UIManager.UIRoot.transform.root.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
41
src/Loader/Standalone/Editor/ExplorerEditorLoader.cs
Normal file
41
src/Loader/Standalone/Editor/ExplorerEditorLoader.cs
Normal file
@ -0,0 +1,41 @@
|
||||
#if STANDALONE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityExplorer.Loader.Standalone
|
||||
{
|
||||
public class ExplorerEditorLoader : ExplorerStandalone
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Instance = new ExplorerEditorLoader();
|
||||
OnLog += LogHandler;
|
||||
Instance.configHandler = new StandaloneConfigHandler();
|
||||
|
||||
ExplorerCore.Init(Instance);
|
||||
}
|
||||
|
||||
static void LogHandler(string message, LogType logType)
|
||||
{
|
||||
switch (logType)
|
||||
{
|
||||
case LogType.Assert: Debug.LogError(message); break;
|
||||
case LogType.Error: Debug.LogError(message); break;
|
||||
case LogType.Exception: Debug.LogError(message); break;
|
||||
case LogType.Log: Debug.Log(message); break;
|
||||
case LogType.Warning: Debug.LogWarning(message); break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CheckExplorerFolder()
|
||||
{
|
||||
if (explorerFolder == null)
|
||||
explorerFolder = Path.Combine(Application.dataPath, "UnityExplorer~");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -5,9 +5,9 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityExplorer.Config;
|
||||
using UnityExplorer.Loader.STANDALONE;
|
||||
using UnityEngine.EventSystems;
|
||||
using UniverseLib.Input;
|
||||
using UnityExplorer.Loader.Standalone;
|
||||
#if CPP
|
||||
using UnhollowerRuntimeLib;
|
||||
#endif
|
||||
@ -16,6 +16,33 @@ namespace UnityExplorer
|
||||
{
|
||||
public class ExplorerStandalone : IExplorerLoader
|
||||
{
|
||||
public static ExplorerStandalone Instance { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoked whenever Explorer logs something. Subscribe to this to handle logging.
|
||||
/// </summary>
|
||||
public static event Action<string, LogType> OnLog;
|
||||
|
||||
public string UnhollowedModulesFolder => unhollowedPath;
|
||||
private string unhollowedPath;
|
||||
|
||||
public ConfigHandler ConfigHandler => configHandler;
|
||||
internal StandaloneConfigHandler configHandler;
|
||||
|
||||
public string ExplorerFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckExplorerFolder();
|
||||
return explorerFolder;
|
||||
}
|
||||
}
|
||||
protected static string explorerFolder;
|
||||
|
||||
Action<object> IExplorerLoader.OnLogMessage => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Log); };
|
||||
Action<object> IExplorerLoader.OnLogWarning => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Warning); };
|
||||
Action<object> IExplorerLoader.OnLogError => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Error); };
|
||||
|
||||
/// <summary>
|
||||
/// Call this to initialize UnityExplorer without adding a log listener or Unhollowed modules path.
|
||||
/// The default Unhollowed path "UnityExplorer\Modules\" will be used.
|
||||
@ -50,60 +77,33 @@ namespace UnityExplorer
|
||||
OnLog += logListener;
|
||||
|
||||
if (string.IsNullOrEmpty(unhollowedModulesPath) || !Directory.Exists(unhollowedModulesPath))
|
||||
instance._unhollowedPath = Path.Combine(instance.ExplorerFolder, "Modules");
|
||||
instance.unhollowedPath = Path.Combine(instance.ExplorerFolder, "Modules");
|
||||
else
|
||||
instance._unhollowedPath = unhollowedModulesPath;
|
||||
instance.unhollowedPath = unhollowedModulesPath;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static ExplorerStandalone Instance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoked whenever Explorer logs something. Subscribe to this to handle logging.
|
||||
/// </summary>
|
||||
public static event Action<string, LogType> OnLog;
|
||||
|
||||
public string UnhollowedModulesFolder => _unhollowedPath;
|
||||
private string _unhollowedPath;
|
||||
|
||||
public ConfigHandler ConfigHandler => _configHandler;
|
||||
private StandaloneConfigHandler _configHandler;
|
||||
|
||||
public string ExplorerFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckExplorerFolder();
|
||||
return s_explorerFolder;
|
||||
}
|
||||
}
|
||||
private static string s_explorerFolder;
|
||||
|
||||
Action<object> IExplorerLoader.OnLogMessage => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Log); };
|
||||
Action<object> IExplorerLoader.OnLogWarning => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Warning); };
|
||||
Action<object> IExplorerLoader.OnLogError => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Error); };
|
||||
|
||||
private void Init()
|
||||
internal void Init()
|
||||
{
|
||||
Instance = this;
|
||||
_configHandler = new StandaloneConfigHandler();
|
||||
configHandler = new StandaloneConfigHandler();
|
||||
|
||||
ExplorerCore.Init(this);
|
||||
}
|
||||
|
||||
private void CheckExplorerFolder()
|
||||
protected virtual void CheckExplorerFolder()
|
||||
{
|
||||
if (s_explorerFolder == null)
|
||||
if (explorerFolder == null)
|
||||
{
|
||||
s_explorerFolder =
|
||||
explorerFolder =
|
||||
Path.Combine(
|
||||
Path.GetDirectoryName(
|
||||
Uri.UnescapeDataString(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath)),
|
||||
"UnityExplorer");
|
||||
|
||||
if (!Directory.Exists(s_explorerFolder))
|
||||
Directory.CreateDirectory(s_explorerFolder);
|
||||
if (!Directory.Exists(explorerFolder))
|
||||
Directory.CreateDirectory(explorerFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using UnityEngine;
|
||||
using Tomlet;
|
||||
using Tomlet.Models;
|
||||
|
||||
namespace UnityExplorer.Loader.STANDALONE
|
||||
namespace UnityExplorer.Loader.Standalone
|
||||
{
|
||||
public class StandaloneConfigHandler : ConfigHandler
|
||||
{
|
||||
|
@ -18,7 +18,10 @@ namespace UnityExplorer.UI
|
||||
public static int Width => ActiveDisplay.renderingWidth;
|
||||
public static int Height => ActiveDisplay.renderingHeight;
|
||||
|
||||
public static Vector3 MousePosition => Display.RelativeMouseAt(InputManager.MousePosition);
|
||||
public static Vector3 MousePosition => Application.isEditor
|
||||
? InputManager.MousePosition
|
||||
: Display.RelativeMouseAt(InputManager.MousePosition);
|
||||
|
||||
public static bool MouseInTargetDisplay => MousePosition.z == ActiveDisplayIndex;
|
||||
|
||||
private static Camera canvasCamera;
|
||||
|
@ -265,6 +265,8 @@
|
||||
<Compile Include="CacheObject\Views\CacheListEntryCell.cs" />
|
||||
<Compile Include="CacheObject\Views\CacheMemberCell.cs" />
|
||||
<Compile Include="CacheObject\Views\CacheObjectCell.cs" />
|
||||
<Compile Include="Loader\Standalone\Editor\ExplorerEditorBehaviour.cs" />
|
||||
<Compile Include="Loader\Standalone\Editor\ExplorerEditorLoader.cs" />
|
||||
<Compile Include="Runtime\UnityCrashPrevention.cs" />
|
||||
<Compile Include="UI\DisplayManager.cs" />
|
||||
<Compile Include="UI\Notification.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user