mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 22:07:48 +08:00
Add keybinds for Mouse Inspect, small cleanup
This commit is contained in:
parent
a7165c849c
commit
ad8c5293a0
@ -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?",
|
||||||
|
@ -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)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user