mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-16 00:07:52 +08:00
Add keybinds for Mouse Inspect, small cleanup
This commit is contained in:
@ -13,6 +13,7 @@ using UnityExplorer.UI.Panels;
|
||||
using UniverseLib;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.Utility;
|
||||
using UnityExplorer.Config;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
{
|
||||
@ -22,9 +23,9 @@ namespace UnityExplorer.Inspectors
|
||||
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 UiInspector uiInspector;
|
||||
@ -58,7 +59,7 @@ namespace UnityExplorer.Inspectors
|
||||
internal Text objPathLabel;
|
||||
internal Text mousePosLabel;
|
||||
|
||||
public InspectUnderMouse()
|
||||
public MouseInspector()
|
||||
{
|
||||
Instance = this;
|
||||
worldInspector = new WorldInspector();
|
||||
@ -116,6 +117,26 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
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()
|
||||
{
|
||||
if (InputManager.GetKeyDown(KeyCode.Escape))
|
@ -26,7 +26,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
public override void OnBeginMouseInspect()
|
||||
{
|
||||
SetupUIRaycast();
|
||||
InspectUnderMouse.Instance.objPathLabel.text = "";
|
||||
MouseInspector.Instance.objPathLabel.text = "";
|
||||
}
|
||||
|
||||
public override void ClearHitData()
|
||||
@ -70,9 +70,9 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
}
|
||||
|
||||
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
|
||||
InspectUnderMouse.Instance.objNameLabel.text = $"No UI objects under mouse.";
|
||||
MouseInspector.Instance.objNameLabel.text = $"No UI objects under mouse.";
|
||||
}
|
||||
|
||||
private static void SetupUIRaycast()
|
||||
|
@ -41,7 +41,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
if (!MainCamera)
|
||||
{
|
||||
ExplorerCore.LogWarning("No Main Camera was found, unable to inspect world!");
|
||||
InspectUnderMouse.Instance.StopInspect();
|
||||
MouseInspector.Instance.StopInspect();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
if (hit.transform)
|
||||
OnHitGameObject(hit.transform.gameObject);
|
||||
else if (lastHitObject)
|
||||
InspectUnderMouse.Instance.ClearHitData();
|
||||
MouseInspector.Instance.ClearHitData();
|
||||
}
|
||||
|
||||
internal void OnHitGameObject(GameObject obj)
|
||||
@ -59,8 +59,8 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
if (obj != lastHitObject)
|
||||
{
|
||||
lastHitObject = obj;
|
||||
InspectUnderMouse.Instance.objNameLabel.text = $"<b>Click to Inspect:</b> <color=cyan>{obj.name}</color>";
|
||||
InspectUnderMouse.Instance.objPathLabel.text = $"Path: {obj.transform.GetTransformPath(true)}";
|
||||
MouseInspector.Instance.objNameLabel.text = $"<b>Click to Inspect:</b> <color=cyan>{obj.name}</color>";
|
||||
MouseInspector.Instance.objPathLabel.text = $"Path: {obj.transform.GetTransformPath(true)}";
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user