mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-23 17:02:36 +08:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
ad8c5293a0 | |||
a7165c849c | |||
79f2514109 | |||
4e76eca73a | |||
2f0876466c | |||
fdefc3d567 | |||
64193ff1b0 | |||
a90292f47f |
Binary file not shown.
Binary file not shown.
@ -21,7 +21,7 @@ namespace UnityExplorer.CacheObject
|
|||||||
{
|
{
|
||||||
public abstract Type DeclaringType { get; }
|
public abstract Type DeclaringType { get; }
|
||||||
public string NameForFiltering { get; protected set; }
|
public string NameForFiltering { get; protected set; }
|
||||||
public object DeclaringInstance => IsStatic ? null : (m_declaringInstance ?? (m_declaringInstance = Owner.Target.TryCast(DeclaringType)));
|
public object DeclaringInstance => IsStatic ? null : (m_declaringInstance ??= Owner.Target.TryCast(DeclaringType));
|
||||||
private object m_declaringInstance;
|
private object m_declaringInstance;
|
||||||
|
|
||||||
public abstract bool IsStatic { get; }
|
public abstract bool IsStatic { get; }
|
||||||
@ -94,8 +94,8 @@ namespace UnityExplorer.CacheObject
|
|||||||
base.SetValueState(cell, args);
|
base.SetValueState(cell, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Color evalEnabledColor = new Color(0.15f, 0.25f, 0.15f);
|
private static readonly Color evalEnabledColor = new(0.15f, 0.25f, 0.15f);
|
||||||
private static readonly Color evalDisabledColor = new Color(0.15f, 0.15f, 0.15f);
|
private static readonly Color evalDisabledColor = new(0.15f, 0.15f, 0.15f);
|
||||||
|
|
||||||
protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell objectcell)
|
protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell objectcell)
|
||||||
{
|
{
|
||||||
@ -242,7 +242,7 @@ namespace UnityExplorer.CacheObject
|
|||||||
|
|
||||||
var sig = GetSig(member);
|
var sig = GetSig(member);
|
||||||
|
|
||||||
//ExplorerCore.Log($"Trying to cache member {sig}... ({member.MemberType})");
|
// ExplorerCore.Log($"Trying to cache member {sig}... ({member.MemberType})");
|
||||||
|
|
||||||
CacheMember cached;
|
CacheMember cached;
|
||||||
Type returnType;
|
Type returnType;
|
||||||
|
@ -3,7 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
using UnityExplorer.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
using UnityExplorer.Runtime;
|
||||||
|
|
||||||
namespace UnityExplorer.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,8 @@ namespace UnityExplorer.Config
|
|||||||
public static ConfigElement<bool> Hide_On_Startup;
|
public static ConfigElement<bool> Hide_On_Startup;
|
||||||
public static ConfigElement<float> Startup_Delay_Time;
|
public static ConfigElement<float> Startup_Delay_Time;
|
||||||
public static ConfigElement<string> Reflection_Signature_Blacklist;
|
public static ConfigElement<string> Reflection_Signature_Blacklist;
|
||||||
|
public static ConfigElement<KeyCode> World_MouseInspect_Keybind;
|
||||||
|
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
|
||||||
|
|
||||||
// internal configs
|
// internal configs
|
||||||
internal static InternalConfigHandler InternalHandler { get; private set; }
|
internal static InternalConfigHandler InternalHandler { get; private set; }
|
||||||
@ -93,13 +95,18 @@ namespace UnityExplorer.Config
|
|||||||
"Should UnityExplorer be hidden on startup?",
|
"Should UnityExplorer be hidden on startup?",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
World_MouseInspect_Keybind = new("World Mouse-Inspect Keybind",
|
||||||
|
"Optional keybind to being a World-mode Mouse Inspect.",
|
||||||
|
KeyCode.None);
|
||||||
|
|
||||||
|
UI_MouseInspect_Keybind = new("UI Mouse-Inspect Keybind",
|
||||||
|
"Optional keybind to begin a UI_mode Mouse Inspect.",
|
||||||
|
KeyCode.None);
|
||||||
|
|
||||||
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
||||||
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
||||||
true);
|
true);
|
||||||
Force_Unlock_Mouse.OnValueChanged += (bool value) =>
|
Force_Unlock_Mouse.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = value;
|
||||||
{
|
|
||||||
UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
Force_Unlock_Toggle = new ConfigElement<KeyCode>("Force Unlock Toggle Key",
|
Force_Unlock_Toggle = new ConfigElement<KeyCode>("Force Unlock Toggle Key",
|
||||||
"The keybind to toggle the 'Force Unlock Mouse' setting. Only usable when UnityExplorer is open.",
|
"The keybind to toggle the 'Force Unlock Mouse' setting. Only usable when UnityExplorer is open.",
|
||||||
@ -108,10 +115,7 @@ namespace UnityExplorer.Config
|
|||||||
Disable_EventSystem_Override = new ConfigElement<bool>("Disable EventSystem override",
|
Disable_EventSystem_Override = new ConfigElement<bool>("Disable EventSystem override",
|
||||||
"If enabled, UnityExplorer will not override the EventSystem from the game.\n<b>May require restart to take effect.</b>",
|
"If enabled, UnityExplorer will not override the EventSystem from the game.\n<b>May require restart to take effect.</b>",
|
||||||
false);
|
false);
|
||||||
Disable_EventSystem_Override.OnValueChanged += (bool value) =>
|
Disable_EventSystem_Override.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Disable_EventSystem_Override = value;
|
||||||
{
|
|
||||||
UniverseLib.Config.ConfigManager.Disable_EventSystem_Override = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
||||||
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
||||||
|
@ -18,7 +18,7 @@ namespace UnityExplorer
|
|||||||
public static class ExplorerCore
|
public static class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "4.5.6";
|
public const string VERSION = "4.5.7";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ namespace UnityExplorer
|
|||||||
ConfigManager.Init(Loader.ConfigHandler);
|
ConfigManager.Init(Loader.ConfigHandler);
|
||||||
UERuntimeHelper.Init();
|
UERuntimeHelper.Init();
|
||||||
ExplorerBehaviour.Setup();
|
ExplorerBehaviour.Setup();
|
||||||
|
UnityCrashPrevention.Init();
|
||||||
|
|
||||||
UniverseLib.Universe.Init(ConfigManager.Startup_Delay_Time.Value, LateInit, Log, new()
|
UniverseLib.Universe.Init(ConfigManager.Startup_Delay_Time.Value, LateInit, Log, new()
|
||||||
{
|
{
|
||||||
@ -68,7 +69,7 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
UIManager.InitUI();
|
UIManager.InitUI();
|
||||||
|
|
||||||
Log($"{NAME} {VERSION} initialized.");
|
Log($"{NAME} {VERSION} initialized for {UniverseLib.Universe.Context}.");
|
||||||
|
|
||||||
//InspectorManager.Inspect(typeof(Tests.TestClass));
|
//InspectorManager.Inspect(typeof(Tests.TestClass));
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
public static class InspectorManager
|
public static class InspectorManager
|
||||||
{
|
{
|
||||||
public static readonly List<InspectorBase> Inspectors = new List<InspectorBase>();
|
public static readonly List<InspectorBase> Inspectors = new();
|
||||||
|
|
||||||
public static InspectorBase ActiveInspector { get; private set; }
|
public static InspectorBase ActiveInspector { get; private set; }
|
||||||
private static InspectorBase lastActiveInspector;
|
private static InspectorBase lastActiveInspector;
|
||||||
@ -94,17 +94,17 @@ namespace UnityExplorer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateInspector<T>(object target, bool staticReflection = false,
|
private static void CreateInspector<T>(object target, bool staticReflection = false,
|
||||||
CacheObjectBase sourceCache = null) where T : InspectorBase
|
CacheObjectBase parentObject = null) where T : InspectorBase
|
||||||
{
|
{
|
||||||
var inspector = Pool<T>.Borrow();
|
var inspector = Pool<T>.Borrow();
|
||||||
Inspectors.Add(inspector);
|
Inspectors.Add(inspector);
|
||||||
inspector.Target = target;
|
inspector.Target = target;
|
||||||
|
|
||||||
if (sourceCache != null && sourceCache.CanWrite)
|
if (parentObject != null && parentObject.CanWrite)
|
||||||
{
|
{
|
||||||
// only set parent cache object if we are inspecting a struct, otherwise there is no point.
|
// only set parent cache object if we are inspecting a struct, otherwise there is no point.
|
||||||
if (target.GetType().IsValueType && inspector is ReflectionInspector ri)
|
if (target.GetType().IsValueType && inspector is ReflectionInspector ri)
|
||||||
ri.ParentCacheObject = sourceCache;
|
ri.ParentCacheObject = parentObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
||||||
|
@ -13,6 +13,7 @@ using UnityExplorer.UI.Panels;
|
|||||||
using UniverseLib;
|
using UniverseLib;
|
||||||
using UniverseLib.UI;
|
using UniverseLib.UI;
|
||||||
using UniverseLib.Utility;
|
using UniverseLib.Utility;
|
||||||
|
using UnityExplorer.Config;
|
||||||
|
|
||||||
namespace UnityExplorer.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
@ -22,9 +23,9 @@ namespace UnityExplorer.Inspectors
|
|||||||
UI
|
UI
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InspectUnderMouse : UIPanel
|
public class MouseInspector : UIPanel
|
||||||
{
|
{
|
||||||
public static InspectUnderMouse Instance { get; private set; }
|
public static MouseInspector Instance { get; private set; }
|
||||||
|
|
||||||
private readonly WorldInspector worldInspector;
|
private readonly WorldInspector worldInspector;
|
||||||
private readonly UiInspector uiInspector;
|
private readonly UiInspector uiInspector;
|
||||||
@ -58,7 +59,7 @@ namespace UnityExplorer.Inspectors
|
|||||||
internal Text objPathLabel;
|
internal Text objPathLabel;
|
||||||
internal Text mousePosLabel;
|
internal Text mousePosLabel;
|
||||||
|
|
||||||
public InspectUnderMouse()
|
public MouseInspector()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
worldInspector = new WorldInspector();
|
worldInspector = new WorldInspector();
|
||||||
@ -116,6 +117,26 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
private static float timeOfLastRaycast;
|
private static float timeOfLastRaycast;
|
||||||
|
|
||||||
|
public bool TryUpdate()
|
||||||
|
{
|
||||||
|
if (ConfigManager.World_MouseInspect_Keybind.Value != KeyCode.None)
|
||||||
|
{
|
||||||
|
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||||
|
Instance.StartInspect(MouseInspectMode.World);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigManager.World_MouseInspect_Keybind.Value != KeyCode.None)
|
||||||
|
{
|
||||||
|
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||||
|
Instance.StartInspect(MouseInspectMode.World);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Inspecting)
|
||||||
|
UpdateInspect();
|
||||||
|
|
||||||
|
return Inspecting;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateInspect()
|
public void UpdateInspect()
|
||||||
{
|
{
|
||||||
if (InputManager.GetKeyDown(KeyCode.Escape))
|
if (InputManager.GetKeyDown(KeyCode.Escape))
|
@ -26,7 +26,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
|||||||
public override void OnBeginMouseInspect()
|
public override void OnBeginMouseInspect()
|
||||||
{
|
{
|
||||||
SetupUIRaycast();
|
SetupUIRaycast();
|
||||||
InspectUnderMouse.Instance.objPathLabel.text = "";
|
MouseInspector.Instance.objPathLabel.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ClearHitData()
|
public override void ClearHitData()
|
||||||
@ -70,9 +70,9 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentHitObjects.Any())
|
if (currentHitObjects.Any())
|
||||||
InspectUnderMouse.Instance.objNameLabel.text = $"Click to view UI Objects under mouse: {currentHitObjects.Count}";
|
MouseInspector.Instance.objNameLabel.text = $"Click to view UI Objects under mouse: {currentHitObjects.Count}";
|
||||||
else
|
else
|
||||||
InspectUnderMouse.Instance.objNameLabel.text = $"No UI objects under mouse.";
|
MouseInspector.Instance.objNameLabel.text = $"No UI objects under mouse.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetupUIRaycast()
|
private static void SetupUIRaycast()
|
||||||
|
@ -41,7 +41,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
|||||||
if (!MainCamera)
|
if (!MainCamera)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning("No Main Camera was found, unable to inspect world!");
|
ExplorerCore.LogWarning("No Main Camera was found, unable to inspect world!");
|
||||||
InspectUnderMouse.Instance.StopInspect();
|
MouseInspector.Instance.StopInspect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
|||||||
if (hit.transform)
|
if (hit.transform)
|
||||||
OnHitGameObject(hit.transform.gameObject);
|
OnHitGameObject(hit.transform.gameObject);
|
||||||
else if (lastHitObject)
|
else if (lastHitObject)
|
||||||
InspectUnderMouse.Instance.ClearHitData();
|
MouseInspector.Instance.ClearHitData();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnHitGameObject(GameObject obj)
|
internal void OnHitGameObject(GameObject obj)
|
||||||
@ -59,8 +59,8 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
|||||||
if (obj != lastHitObject)
|
if (obj != lastHitObject)
|
||||||
{
|
{
|
||||||
lastHitObject = obj;
|
lastHitObject = obj;
|
||||||
InspectUnderMouse.Instance.objNameLabel.text = $"<b>Click to Inspect:</b> <color=cyan>{obj.name}</color>";
|
MouseInspector.Instance.objNameLabel.text = $"<b>Click to Inspect:</b> <color=cyan>{obj.name}</color>";
|
||||||
InspectUnderMouse.Instance.objPathLabel.text = $"Path: {obj.transform.GetTransformPath(true)}";
|
MouseInspector.Instance.objPathLabel.text = $"Path: {obj.transform.GetTransformPath(true)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ namespace UnityExplorer
|
|||||||
public ConfigHandler ConfigHandler => _configHandler;
|
public ConfigHandler ConfigHandler => _configHandler;
|
||||||
public MelonLoaderConfigHandler _configHandler;
|
public MelonLoaderConfigHandler _configHandler;
|
||||||
|
|
||||||
public Action<object> OnLogMessage => MelonLogger.Msg;
|
public Action<object> OnLogMessage => LoggerInstance.Msg;
|
||||||
public Action<object> OnLogWarning => MelonLogger.Warning;
|
public Action<object> OnLogWarning => LoggerInstance.Warning;
|
||||||
public Action<object> OnLogError => MelonLogger.Error;
|
public Action<object> OnLogError => LoggerInstance.Error;
|
||||||
|
|
||||||
public override void OnApplicationStart()
|
public override void OnApplicationStart()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
Parent = parent;
|
Parent = parent;
|
||||||
|
|
||||||
SceneHandler.OnInspectedSceneChanged += SceneHandler_OnInspectedSceneChanged;
|
SceneHandler.OnInspectedSceneChanged += SceneHandler_OnInspectedSceneChanged;
|
||||||
SceneHandler.OnLoadedScenesChanged += SceneHandler_OnLoadedScenesChanged;
|
SceneHandler.OnLoadedScenesUpdated += SceneHandler_OnLoadedScenesUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override GameObject UIRoot => uiRoot;
|
public override GameObject UIRoot => uiRoot;
|
||||||
@ -87,7 +87,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
Tree.JumpAndExpandToTransform(transform);
|
Tree.JumpAndExpandToTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDropdownChanged(int value)
|
private void OnSceneSelectionDropdownChanged(int value)
|
||||||
{
|
{
|
||||||
if (value < 0 || SceneHandler.LoadedScenes.Count <= value)
|
if (value < 0 || SceneHandler.LoadedScenes.Count <= value)
|
||||||
return;
|
return;
|
||||||
@ -101,7 +101,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
private void SceneHandler_OnInspectedSceneChanged(Scene scene)
|
private void SceneHandler_OnInspectedSceneChanged(Scene scene)
|
||||||
{
|
{
|
||||||
if (!sceneToDropdownOption.ContainsKey(scene))
|
if (!sceneToDropdownOption.ContainsKey(scene))
|
||||||
PopulateSceneDropdown();
|
PopulateSceneDropdown(SceneHandler.LoadedScenes);
|
||||||
|
|
||||||
if (sceneToDropdownOption.ContainsKey(scene))
|
if (sceneToDropdownOption.ContainsKey(scene))
|
||||||
{
|
{
|
||||||
@ -122,17 +122,17 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
refreshRow.SetActive(!scene.IsValid());
|
refreshRow.SetActive(!scene.IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SceneHandler_OnLoadedScenesChanged(List<Scene> loadedScenes)
|
private void SceneHandler_OnLoadedScenesUpdated(List<Scene> loadedScenes)
|
||||||
{
|
{
|
||||||
PopulateSceneDropdown();
|
PopulateSceneDropdown(loadedScenes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateSceneDropdown()
|
private void PopulateSceneDropdown(List<Scene> loadedScenes)
|
||||||
{
|
{
|
||||||
sceneToDropdownOption.Clear();
|
sceneToDropdownOption.Clear();
|
||||||
sceneDropdown.options.Clear();
|
sceneDropdown.options.Clear();
|
||||||
|
|
||||||
foreach (var scene in SceneHandler.LoadedScenes)
|
foreach (var scene in loadedScenes)
|
||||||
{
|
{
|
||||||
if (sceneToDropdownOption.ContainsKey(scene))
|
if (sceneToDropdownOption.ContainsKey(scene))
|
||||||
continue;
|
continue;
|
||||||
@ -198,11 +198,11 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
var dropLabel = UIFactory.CreateLabel(dropRow, "SelectorLabel", "Scene:", TextAnchor.MiddleLeft, Color.cyan, false, 15);
|
var dropLabel = UIFactory.CreateLabel(dropRow, "SelectorLabel", "Scene:", TextAnchor.MiddleLeft, Color.cyan, false, 15);
|
||||||
UIFactory.SetLayoutElement(dropLabel.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(dropLabel.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0);
|
||||||
|
|
||||||
var dropdownObj = UIFactory.CreateDropdown(dropRow, "SceneDropdown", out sceneDropdown, "<notset>", 13, OnDropdownChanged);
|
var dropdownObj = UIFactory.CreateDropdown(dropRow, "SceneDropdown", out sceneDropdown, "<notset>", 13, OnSceneSelectionDropdownChanged);
|
||||||
UIFactory.SetLayoutElement(dropdownObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
UIFactory.SetLayoutElement(dropdownObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
||||||
|
|
||||||
SceneHandler.Update();
|
SceneHandler.Update();
|
||||||
PopulateSceneDropdown();
|
PopulateSceneDropdown(SceneHandler.LoadedScenes);
|
||||||
sceneDropdown.captionText.text = sceneToDropdownOption.First().Value.text;
|
sceneDropdown.captionText.text = sceneToDropdownOption.First().Value.text;
|
||||||
|
|
||||||
// Filter row
|
// Filter row
|
||||||
|
@ -17,7 +17,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
get => selectedScene;
|
get => selectedScene;
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (selectedScene != null && selectedScene == value)
|
if (selectedScene.HasValue && selectedScene == value)
|
||||||
return;
|
return;
|
||||||
selectedScene = value;
|
selectedScene = value;
|
||||||
OnInspectedSceneChanged?.Invoke((Scene)selectedScene);
|
OnInspectedSceneChanged?.Invoke((Scene)selectedScene);
|
||||||
@ -30,7 +30,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
|
|
||||||
/// <summary>All currently loaded Scenes.</summary>
|
/// <summary>All currently loaded Scenes.</summary>
|
||||||
public static List<Scene> LoadedScenes { get; private set; } = new();
|
public static List<Scene> LoadedScenes { get; private set; } = new();
|
||||||
private static HashSet<Scene> previousLoadedScenes;
|
//private static HashSet<Scene> previousLoadedScenes;
|
||||||
|
|
||||||
/// <summary>The names of all scenes in the build settings, if they could be retrieved.</summary>
|
/// <summary>The names of all scenes in the build settings, if they could be retrieved.</summary>
|
||||||
public static List<string> AllSceneNames { get; private set; } = new();
|
public static List<string> AllSceneNames { get; private set; } = new();
|
||||||
@ -39,7 +39,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
public static event Action<Scene> OnInspectedSceneChanged;
|
public static event Action<Scene> OnInspectedSceneChanged;
|
||||||
|
|
||||||
/// <summary>Invoked whenever the list of currently loaded Scenes changes. The argument contains all loaded scenes after the change.</summary>
|
/// <summary>Invoked whenever the list of currently loaded Scenes changes. The argument contains all loaded scenes after the change.</summary>
|
||||||
public static event Action<List<Scene>> OnLoadedScenesChanged;
|
public static event Action<List<Scene>> OnLoadedScenesUpdated;
|
||||||
|
|
||||||
/// <summary>Generally will be 2, unless DontDestroyExists == false, then this will be 1.</summary>
|
/// <summary>Generally will be 2, unless DontDestroyExists == false, then this will be 1.</summary>
|
||||||
internal static int DefaultSceneCount => 1 + (DontDestroyExists ? 1 : 0);
|
internal static int DefaultSceneCount => 1 + (DontDestroyExists ? 1 : 0);
|
||||||
@ -84,23 +84,20 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
|
|
||||||
internal static void Update()
|
internal static void Update()
|
||||||
{
|
{
|
||||||
// check if the loaded scenes changed. always confirm DontDestroy / HideAndDontSave
|
// Inspected scene will exist if it's DontDestroyOnLoad or HideAndDontSave
|
||||||
int confirmedCount = DefaultSceneCount;
|
bool inspectedExists =
|
||||||
bool inspectedExists = (SelectedScene.HasValue && SelectedScene.Value.handle == -12)
|
SelectedScene.HasValue
|
||||||
|| (SelectedScene.HasValue && SelectedScene.Value.handle == -1);
|
&& ((DontDestroyExists && SelectedScene.Value.handle == -12)
|
||||||
|
|| SelectedScene.Value.handle == -1);
|
||||||
|
|
||||||
LoadedScenes.Clear();
|
LoadedScenes.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||||
{
|
{
|
||||||
Scene scene = SceneManager.GetSceneAt(i);
|
Scene scene = SceneManager.GetSceneAt(i);
|
||||||
if (scene == default || !scene.isLoaded)
|
if (scene == default || !scene.isLoaded || !scene.IsValid())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If no changes yet, ensure the previous list contained the scene
|
|
||||||
if (previousLoadedScenes != null && previousLoadedScenes.Contains(scene))
|
|
||||||
confirmedCount++;
|
|
||||||
|
|
||||||
// If we have not yet confirmed inspectedExists, check if this scene is our currently inspected one.
|
// If we have not yet confirmed inspectedExists, check if this scene is our currently inspected one.
|
||||||
if (!inspectedExists && scene == SelectedScene)
|
if (!inspectedExists && scene == SelectedScene)
|
||||||
inspectedExists = true;
|
inspectedExists = true;
|
||||||
@ -112,17 +109,12 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
LoadedScenes.Add(new Scene { m_Handle = -12 });
|
LoadedScenes.Add(new Scene { m_Handle = -12 });
|
||||||
LoadedScenes.Add(new Scene { m_Handle = -1 });
|
LoadedScenes.Add(new Scene { m_Handle = -1 });
|
||||||
|
|
||||||
bool anyChange = confirmedCount != LoadedScenes.Count;
|
|
||||||
|
|
||||||
previousLoadedScenes = new HashSet<Scene>(LoadedScenes);
|
|
||||||
|
|
||||||
// Default to first scene if none selected or previous selection no longer exists.
|
// Default to first scene if none selected or previous selection no longer exists.
|
||||||
if (!inspectedExists)
|
if (!inspectedExists)
|
||||||
SelectedScene = LoadedScenes.First();
|
SelectedScene = LoadedScenes.First();
|
||||||
|
|
||||||
// Notify on the list changing at all
|
// Notify on the list changing at all
|
||||||
if (anyChange)
|
OnLoadedScenesUpdated?.Invoke(LoadedScenes);
|
||||||
OnLoadedScenesChanged?.Invoke(LoadedScenes);
|
|
||||||
|
|
||||||
// Finally, update the root objects list.
|
// Finally, update the root objects list.
|
||||||
if (SelectedScene != null && ((Scene)SelectedScene).IsValid())
|
if (SelectedScene != null && ((Scene)SelectedScene).IsValid())
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#if MONO
|
#if MONO
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.Runtime
|
namespace UnityExplorer.Runtime
|
||||||
|
38
src/Runtime/UnityCrashPrevention.cs
Normal file
38
src/Runtime/UnityCrashPrevention.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityExplorer.CacheObject;
|
||||||
|
|
||||||
|
namespace UnityExplorer.Runtime
|
||||||
|
{
|
||||||
|
internal static class UnityCrashPrevention
|
||||||
|
{
|
||||||
|
internal static void Init()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ExplorerCore.Harmony.PatchAll(typeof(UnityCrashPrevention));
|
||||||
|
ExplorerCore.Log("Initialized UnityCrashPrevention.");
|
||||||
|
}
|
||||||
|
catch //(Exception ex)
|
||||||
|
{
|
||||||
|
//ExplorerCore.Log($"Exception setting up Canvas crash prevention patch: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In Unity 2020 they introduced "Canvas.renderingDisplaySize".
|
||||||
|
// If you try to get the value on a Canvas which has a renderMode value of WorldSpace and no worldCamera set,
|
||||||
|
// the game will Crash (I think from Unity trying to read from null ptr).
|
||||||
|
[HarmonyPatch(typeof(Canvas), "renderingDisplaySize", MethodType.Getter)]
|
||||||
|
[HarmonyPrefix]
|
||||||
|
internal static void Prefix_Canvas_renderingDisplaySize(Canvas __instance)
|
||||||
|
{
|
||||||
|
if (__instance.renderMode == RenderMode.WorldSpace && !__instance.worldCamera)
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Canvas is set to RenderMode.WorldSpace but not worldCamera is set, cannot get renderingDisplaySize.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -152,16 +152,16 @@ namespace UnityExplorer.Tests
|
|||||||
public static Il2CppReferenceArray<Il2CppSystem.Object> IL2CPP_ReferenceArray;
|
public static Il2CppReferenceArray<Il2CppSystem.Object> IL2CPP_ReferenceArray;
|
||||||
public static Il2CppSystem.Collections.IDictionary IL2CPP_IDict;
|
public static Il2CppSystem.Collections.IDictionary IL2CPP_IDict;
|
||||||
public static Il2CppSystem.Collections.IList IL2CPP_IList;
|
public static Il2CppSystem.Collections.IList IL2CPP_IList;
|
||||||
public static Dictionary<Il2CppSystem.String, Il2CppSystem.Object> CppBoxedDict;
|
public static Dictionary<Il2CppSystem.Object, Il2CppSystem.Object> IL2CPP_BoxedDict;
|
||||||
|
|
||||||
public static Il2CppSystem.Collections.Generic.HashSet<string> IL2CPP_HashSet;
|
public static Il2CppSystem.Collections.Generic.HashSet<string> IL2CPP_HashSet;
|
||||||
public static Il2CppSystem.Collections.Generic.Dictionary<string, string> IL2CPP_Dict;
|
public static Il2CppSystem.Collections.Generic.Dictionary<string, string> IL2CPP_Dict;
|
||||||
public static Il2CppSystem.Collections.Hashtable IL2CPP_HashTable;
|
public static Il2CppSystem.Collections.Hashtable IL2CPP_HashTable;
|
||||||
public static Il2CppSystem.Object cppBoxedInt;
|
public static Il2CppSystem.Object IL2CPP_BoxedInt;
|
||||||
public static Il2CppSystem.Int32 cppInt;
|
public static Il2CppSystem.Int32 IL2CPP_Int;
|
||||||
public static Il2CppSystem.Decimal cppDecimal;
|
public static Il2CppSystem.Decimal IL2CPP_Decimal;
|
||||||
public static Il2CppSystem.Object cppDecimalBoxed;
|
public static Il2CppSystem.Object IL2CPP_DecimalBoxed;
|
||||||
public static Il2CppSystem.Object cppVector3Boxed;
|
public static Il2CppSystem.Object IL2CPP_Vector3Boxed;
|
||||||
public static string IL2CPP_systemString = "Test";
|
public static string IL2CPP_systemString = "Test";
|
||||||
public static Il2CppSystem.Object IL2CPP_objectString = "string boxed as cpp object";
|
public static Il2CppSystem.Object IL2CPP_objectString = "string boxed as cpp object";
|
||||||
public static Il2CppSystem.String IL2CPP_il2cppString = "string boxed as cpp string";
|
public static Il2CppSystem.String IL2CPP_il2cppString = "string boxed as cpp string";
|
||||||
@ -203,11 +203,11 @@ namespace UnityExplorer.Tests
|
|||||||
IL2CPP_HashSet.Add("two");
|
IL2CPP_HashSet.Add("two");
|
||||||
|
|
||||||
ExplorerCore.Log($"IL2CPP 7: Dictionary of Il2Cpp String and Il2Cpp Object");
|
ExplorerCore.Log($"IL2CPP 7: Dictionary of Il2Cpp String and Il2Cpp Object");
|
||||||
CppBoxedDict = new Dictionary<Il2CppSystem.String, Il2CppSystem.Object>();
|
IL2CPP_BoxedDict = new();
|
||||||
CppBoxedDict.Add("1", new Il2CppSystem.Int32 { m_value = 1 }.BoxIl2CppObject());
|
IL2CPP_BoxedDict[(Il2CppSystem.String)"one"] = new Il2CppSystem.Int32 { m_value = 1 }.BoxIl2CppObject();
|
||||||
CppBoxedDict.Add("2", new Il2CppSystem.Int32 { m_value = 2 }.BoxIl2CppObject());
|
IL2CPP_BoxedDict[(Il2CppSystem.String)"two"] = new Il2CppSystem.Int32 { m_value = 2 }.BoxIl2CppObject();
|
||||||
CppBoxedDict.Add("3", new Il2CppSystem.Int32 { m_value = 3 }.BoxIl2CppObject());
|
IL2CPP_BoxedDict[(Il2CppSystem.String)"three"] = new Il2CppSystem.Int32 { m_value = 3 }.BoxIl2CppObject();
|
||||||
CppBoxedDict.Add("4", new Il2CppSystem.Int32 { m_value = 4 }.BoxIl2CppObject());
|
IL2CPP_BoxedDict[(Il2CppSystem.String)"four"] = new Il2CppSystem.Int32 { m_value = 4 }.BoxIl2CppObject();
|
||||||
|
|
||||||
ExplorerCore.Log($"IL2CPP 8: List of boxed Il2Cpp Objects");
|
ExplorerCore.Log($"IL2CPP 8: List of boxed Il2Cpp Objects");
|
||||||
IL2CPP_listOfBoxedObjects = new List<Il2CppSystem.Object>();
|
IL2CPP_listOfBoxedObjects = new List<Il2CppSystem.Object>();
|
||||||
@ -248,11 +248,11 @@ namespace UnityExplorer.Tests
|
|||||||
IL2CPP_ReferenceArray[2] = (Il2CppSystem.String)"whats up";
|
IL2CPP_ReferenceArray[2] = (Il2CppSystem.String)"whats up";
|
||||||
|
|
||||||
ExplorerCore.Log($"IL2CPP 11: Misc il2cpp members");
|
ExplorerCore.Log($"IL2CPP 11: Misc il2cpp members");
|
||||||
cppBoxedInt = new Il2CppSystem.Int32() { m_value = 5 }.BoxIl2CppObject();
|
IL2CPP_BoxedInt = new Il2CppSystem.Int32() { m_value = 5 }.BoxIl2CppObject();
|
||||||
cppInt = new Il2CppSystem.Int32 { m_value = 420 };
|
IL2CPP_Int = new Il2CppSystem.Int32 { m_value = 420 };
|
||||||
cppDecimal = new Il2CppSystem.Decimal(1f);
|
IL2CPP_Decimal = new Il2CppSystem.Decimal(1f);
|
||||||
cppDecimalBoxed = new Il2CppSystem.Decimal(1f).BoxIl2CppObject();
|
IL2CPP_DecimalBoxed = new Il2CppSystem.Decimal(1f).BoxIl2CppObject();
|
||||||
cppVector3Boxed = Vector3.down.BoxIl2CppObject();
|
IL2CPP_Vector3Boxed = Vector3.down.BoxIl2CppObject();
|
||||||
|
|
||||||
ExplorerCore.Log($"Finished Init_Il2Cpp");
|
ExplorerCore.Log($"Finished Init_Il2Cpp");
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
// Inspect under mouse dropdown on title bar
|
// Inspect under mouse dropdown on title bar
|
||||||
|
|
||||||
var mouseDropdown = UIFactory.CreateDropdown(closeHolder, "MouseInspectDropdown", out MouseInspectDropdown, "Mouse Inspect", 14,
|
var mouseDropdown = UIFactory.CreateDropdown(closeHolder, "MouseInspectDropdown", out MouseInspectDropdown, "Mouse Inspect", 14,
|
||||||
InspectUnderMouse.OnDropdownSelect);
|
MouseInspector.OnDropdownSelect);
|
||||||
UIFactory.SetLayoutElement(mouseDropdown, minHeight: 25, minWidth: 140);
|
UIFactory.SetLayoutElement(mouseDropdown, minHeight: 25, minWidth: 140);
|
||||||
MouseInspectDropdown.options.Add(new Dropdown.OptionData("Mouse Inspect"));
|
MouseInspectDropdown.options.Add(new Dropdown.OptionData("Mouse Inspect"));
|
||||||
MouseInspectDropdown.options.Add(new Dropdown.OptionData("World"));
|
MouseInspectDropdown.options.Add(new Dropdown.OptionData("World"));
|
||||||
|
@ -73,7 +73,7 @@ namespace UnityExplorer.UI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
UniversalUI.SetUIActive(ExplorerCore.GUID, value);
|
UniversalUI.SetUIActive(ExplorerCore.GUID, value);
|
||||||
UniversalUI.SetUIActive(InspectUnderMouse.UIBaseGUID, value);
|
UniversalUI.SetUIActive(MouseInspector.UIBaseGUID, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ namespace UnityExplorer.UI
|
|||||||
UIPanels.Add(Panels.ConsoleLog, new LogPanel());
|
UIPanels.Add(Panels.ConsoleLog, new LogPanel());
|
||||||
UIPanels.Add(Panels.Options, new OptionsPanel());
|
UIPanels.Add(Panels.Options, new OptionsPanel());
|
||||||
UIPanels.Add(Panels.UIInspectorResults, new UiInspectorResultsPanel());
|
UIPanels.Add(Panels.UIInspectorResults, new UiInspectorResultsPanel());
|
||||||
UIPanels.Add(Panels.MouseInspector, new InspectUnderMouse());
|
UIPanels.Add(Panels.MouseInspector, new MouseInspector());
|
||||||
|
|
||||||
foreach (var panel in UIPanels.Values)
|
foreach (var panel in UIPanels.Values)
|
||||||
panel.ConstructUI();
|
panel.ConstructUI();
|
||||||
@ -135,12 +135,9 @@ namespace UnityExplorer.UI
|
|||||||
if (!UIRoot)
|
if (!UIRoot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if doing Mouse Inspect, update that and return.
|
// If we are doing a Mouse Inspect, we don't need to update anything else.
|
||||||
if (InspectUnderMouse.Inspecting)
|
if (MouseInspector.Instance.TryUpdate())
|
||||||
{
|
|
||||||
InspectUnderMouse.Instance.UpdateInspect();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Update Notification modal
|
// Update Notification modal
|
||||||
Notification.Update();
|
Notification.Update();
|
||||||
|
@ -175,13 +175,13 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UniverseLib.Mono">
|
<Reference Include="UniverseLib.Mono">
|
||||||
<HintPath>packages\UniverseLib.1.2.8\lib\net35\UniverseLib.Mono.dll</HintPath>
|
<HintPath>packages\UniverseLib.1.2.9\lib\net35\UniverseLib.Mono.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- Il2Cpp refs -->
|
<!-- Il2Cpp refs -->
|
||||||
<ItemGroup Condition="'$(IsCpp)'=='true'">
|
<ItemGroup Condition="'$(IsCpp)'=='true'">
|
||||||
<Reference Include="UniverseLib.IL2CPP">
|
<Reference Include="UniverseLib.IL2CPP">
|
||||||
<HintPath>packages\UniverseLib.1.2.8\lib\net472\UniverseLib.IL2CPP.dll</HintPath>
|
<HintPath>packages\UniverseLib.1.2.9\lib\net472\UniverseLib.IL2CPP.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnhollowerBaseLib, Version=0.4.22.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="UnhollowerBaseLib, Version=0.4.22.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Il2CppAssemblyUnhollower.BaseLib.0.4.22\lib\net472\UnhollowerBaseLib.dll</HintPath>
|
<HintPath>packages\Il2CppAssemblyUnhollower.BaseLib.0.4.22\lib\net472\UnhollowerBaseLib.dll</HintPath>
|
||||||
@ -246,7 +246,7 @@
|
|||||||
<Compile Include="Inspectors\GameObjectWidgets\ComponentCell.cs" />
|
<Compile Include="Inspectors\GameObjectWidgets\ComponentCell.cs" />
|
||||||
<Compile Include="Inspectors\GameObjectWidgets\ComponentList.cs" />
|
<Compile Include="Inspectors\GameObjectWidgets\ComponentList.cs" />
|
||||||
<Compile Include="Inspectors\GameObjectWidgets\GameObjectControls.cs" />
|
<Compile Include="Inspectors\GameObjectWidgets\GameObjectControls.cs" />
|
||||||
<Compile Include="Inspectors\InspectUnderMouse.cs" />
|
<Compile Include="Inspectors\MouseInspector.cs" />
|
||||||
<Compile Include="CSConsole\ConsoleController.cs" />
|
<Compile Include="CSConsole\ConsoleController.cs" />
|
||||||
<Compile Include="CacheObject\CacheField.cs" />
|
<Compile Include="CacheObject\CacheField.cs" />
|
||||||
<Compile Include="CacheObject\CacheKeyValuePair.cs" />
|
<Compile Include="CacheObject\CacheKeyValuePair.cs" />
|
||||||
@ -259,6 +259,7 @@
|
|||||||
<Compile Include="CacheObject\Views\CacheListEntryCell.cs" />
|
<Compile Include="CacheObject\Views\CacheListEntryCell.cs" />
|
||||||
<Compile Include="CacheObject\Views\CacheMemberCell.cs" />
|
<Compile Include="CacheObject\Views\CacheMemberCell.cs" />
|
||||||
<Compile Include="CacheObject\Views\CacheObjectCell.cs" />
|
<Compile Include="CacheObject\Views\CacheObjectCell.cs" />
|
||||||
|
<Compile Include="Runtime\UnityCrashPrevention.cs" />
|
||||||
<Compile Include="UI\DisplayManager.cs" />
|
<Compile Include="UI\DisplayManager.cs" />
|
||||||
<Compile Include="UI\Notification.cs" />
|
<Compile Include="UI\Notification.cs" />
|
||||||
<Compile Include="UI\Panels\ClipboardPanel.cs" />
|
<Compile Include="UI\Panels\ClipboardPanel.cs" />
|
||||||
|
@ -6,6 +6,6 @@
|
|||||||
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.2" targetFramework="net35" />
|
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.2" targetFramework="net35" />
|
||||||
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
|
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
|
||||||
<package id="Samboy063.Tomlet" version="3.1.3" targetFramework="net472" />
|
<package id="Samboy063.Tomlet" version="3.1.3" targetFramework="net472" />
|
||||||
<package id="UniverseLib" version="1.2.8" targetFramework="net35" />
|
<package id="UniverseLib" version="1.2.9" targetFramework="net35" />
|
||||||
<package id="UniverseLib.Analyzers" version="1.0.3" targetFramework="net35" developmentDependency="true" />
|
<package id="UniverseLib.Analyzers" version="1.0.3" targetFramework="net35" developmentDependency="true" />
|
||||||
</packages>
|
</packages>
|
Reference in New Issue
Block a user