mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2024-12-23 01:59:40 +08:00
Add support for opening inspected Type in dnSpy
This commit is contained in:
parent
4599747bfe
commit
a1fab0c4a7
@ -16,17 +16,17 @@ namespace UnityExplorer.Config
|
|||||||
|
|
||||||
// Actual UE Settings
|
// Actual UE Settings
|
||||||
public static ConfigElement<KeyCode> Master_Toggle;
|
public static ConfigElement<KeyCode> Master_Toggle;
|
||||||
public static ConfigElement<int> Target_Display;
|
|
||||||
public static ConfigElement<UIManager.VerticalAnchor> Main_Navbar_Anchor;
|
|
||||||
public static ConfigElement<bool> Force_Unlock_Mouse;
|
|
||||||
public static ConfigElement<KeyCode> Force_Unlock_Toggle;
|
|
||||||
public static ConfigElement<bool> Aggressive_Mouse_Unlock;
|
|
||||||
public static ConfigElement<bool> Disable_EventSystem_Override;
|
|
||||||
public static ConfigElement<string> Default_Output_Path;
|
|
||||||
public static ConfigElement<bool> Log_Unity_Debug;
|
|
||||||
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<bool> Disable_EventSystem_Override;
|
||||||
|
public static ConfigElement<int> Target_Display;
|
||||||
|
public static ConfigElement<bool> Force_Unlock_Mouse;
|
||||||
|
public static ConfigElement<KeyCode> Force_Unlock_Toggle;
|
||||||
|
public static ConfigElement<string> Default_Output_Path;
|
||||||
|
public static ConfigElement<string> DnSpy_Path;
|
||||||
|
public static ConfigElement<bool> Log_Unity_Debug;
|
||||||
public static ConfigElement<string> Reflection_Signature_Blacklist;
|
public static ConfigElement<string> Reflection_Signature_Blacklist;
|
||||||
|
public static ConfigElement<UIManager.VerticalAnchor> Main_Navbar_Anchor;
|
||||||
public static ConfigElement<KeyCode> World_MouseInspect_Keybind;
|
public static ConfigElement<KeyCode> World_MouseInspect_Keybind;
|
||||||
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
|
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
|
||||||
|
|
||||||
@ -85,23 +85,15 @@ namespace UnityExplorer.Config
|
|||||||
"Should UnityExplorer be hidden on startup?",
|
"Should UnityExplorer be hidden on startup?",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
Startup_Delay_Time = new ConfigElement<float>("Startup Delay Time",
|
||||||
|
"The delay on startup before the UI is created.",
|
||||||
|
1f);
|
||||||
|
|
||||||
Target_Display = new ConfigElement<int>("Target Display",
|
Target_Display = new ConfigElement<int>("Target Display",
|
||||||
"The monitor index for UnityExplorer to use, if you have multiple. 0 is the default display, 1 is secondary, etc. " +
|
"The monitor index for UnityExplorer to use, if you have multiple. 0 is the default display, 1 is secondary, etc. " +
|
||||||
"Restart recommended when changing this setting. Make sure your extra monitors are the same resolution as your primary monitor.",
|
"Restart recommended when changing this setting. Make sure your extra monitors are the same resolution as your primary monitor.",
|
||||||
0);
|
0);
|
||||||
|
|
||||||
Main_Navbar_Anchor = new ConfigElement<UIManager.VerticalAnchor>("Main Navbar Anchor",
|
|
||||||
"The vertical anchor of the main UnityExplorer Navbar, in case you want to move it.",
|
|
||||||
UIManager.VerticalAnchor.Top);
|
|
||||||
|
|
||||||
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);
|
||||||
@ -116,17 +108,29 @@ namespace UnityExplorer.Config
|
|||||||
false);
|
false);
|
||||||
Disable_EventSystem_Override.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Disable_EventSystem_Override = value;
|
Disable_EventSystem_Override.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Disable_EventSystem_Override = value;
|
||||||
|
|
||||||
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
|
||||||
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
|
||||||
false);
|
|
||||||
|
|
||||||
Default_Output_Path = new ConfigElement<string>("Default Output Path",
|
Default_Output_Path = new ConfigElement<string>("Default Output Path",
|
||||||
"The default output path when exporting things from UnityExplorer.",
|
"The default output path when exporting things from UnityExplorer.",
|
||||||
Path.Combine(ExplorerCore.ExplorerFolder, "Output"));
|
Path.Combine(ExplorerCore.ExplorerFolder, "Output"));
|
||||||
|
|
||||||
Startup_Delay_Time = new ConfigElement<float>("Startup Delay Time",
|
DnSpy_Path = new ConfigElement<string>("dnSpy Path",
|
||||||
"The delay on startup before the UI is created.",
|
"The full path to dnSpy.exe (64-bit).",
|
||||||
1f);
|
@"C:/Program Files/dnspy/dnSpy.exe");
|
||||||
|
|
||||||
|
Main_Navbar_Anchor = new ConfigElement<UIManager.VerticalAnchor>("Main Navbar Anchor",
|
||||||
|
"The vertical anchor of the main UnityExplorer Navbar, in case you want to move it.",
|
||||||
|
UIManager.VerticalAnchor.Top);
|
||||||
|
|
||||||
|
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
||||||
|
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
||||||
|
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);
|
||||||
|
|
||||||
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
|
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
|
||||||
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\n" +
|
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\n" +
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
@ -8,6 +9,8 @@ using UnityEngine;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
|
using UnityExplorer.Config;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
using UniverseLib;
|
using UniverseLib;
|
||||||
@ -33,7 +36,6 @@ namespace UnityExplorer.Inspectors
|
|||||||
public class ReflectionInspector : InspectorBase, ICellPoolDataSource<CacheMemberCell>, ICacheObjectController
|
public class ReflectionInspector : InspectorBase, ICellPoolDataSource<CacheMemberCell>, ICacheObjectController
|
||||||
{
|
{
|
||||||
public CacheObjectBase ParentCacheObject { get; set; }
|
public CacheObjectBase ParentCacheObject { get; set; }
|
||||||
//public Type TargetType { get; private set; }
|
|
||||||
public bool StaticOnly { get; internal set; }
|
public bool StaticOnly { get; internal set; }
|
||||||
public bool CanWrite => true;
|
public bool CanWrite => true;
|
||||||
|
|
||||||
@ -73,6 +75,8 @@ namespace UnityExplorer.Inspectors
|
|||||||
Text assemblyText;
|
Text assemblyText;
|
||||||
Toggle autoUpdateToggle;
|
Toggle autoUpdateToggle;
|
||||||
|
|
||||||
|
ButtonRef dnSpyButton;
|
||||||
|
|
||||||
ButtonRef makeGenericButton;
|
ButtonRef makeGenericButton;
|
||||||
GenericConstructorWidget genericConstructor;
|
GenericConstructorWidget genericConstructor;
|
||||||
|
|
||||||
@ -155,9 +159,15 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
string asmText;
|
string asmText;
|
||||||
if (TargetType.Assembly is AssemblyBuilder || string.IsNullOrEmpty(TargetType.Assembly.Location))
|
if (TargetType.Assembly is AssemblyBuilder || string.IsNullOrEmpty(TargetType.Assembly.Location))
|
||||||
|
{
|
||||||
asmText = $"{TargetType.Assembly.GetName().Name} <color=grey><i>(in memory)</i></color>";
|
asmText = $"{TargetType.Assembly.GetName().Name} <color=grey><i>(in memory)</i></color>";
|
||||||
|
dnSpyButton.GameObject.SetActive(false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
asmText = Path.GetFileName(TargetType.Assembly.Location);
|
asmText = Path.GetFileName(TargetType.Assembly.Location);
|
||||||
|
dnSpyButton.GameObject.SetActive(true);
|
||||||
|
}
|
||||||
assemblyText.text = $"<color=grey>Assembly:</color> {asmText}";
|
assemblyText.text = $"<color=grey>Assembly:</color> {asmText}";
|
||||||
|
|
||||||
// Unity object helper widget
|
// Unity object helper widget
|
||||||
@ -350,6 +360,25 @@ namespace UnityExplorer.Inspectors
|
|||||||
ClipboardPanel.Copy(this.Target ?? this.TargetType);
|
ClipboardPanel.Copy(this.Target ?? this.TargetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDnSpyButtonClicked()
|
||||||
|
{
|
||||||
|
string path = ConfigManager.DnSpy_Path.Value;
|
||||||
|
if (File.Exists(path) && path.EndsWith("dnspy.exe", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
Type type = TargetType;
|
||||||
|
// if constructed generic type, use the generic type definition
|
||||||
|
if (type.IsGenericType && !type.IsGenericTypeDefinition)
|
||||||
|
type = type.GetGenericTypeDefinition();
|
||||||
|
|
||||||
|
string args = $"\"{type.Assembly.Location}\" --select T:{type.FullName}";
|
||||||
|
Process.Start(path, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notification.ShowMessage($"Please set a valid dnSpy path in UnityExplorer Settings.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnMakeGenericClicked()
|
void OnMakeGenericClicked()
|
||||||
{
|
{
|
||||||
ContentRoot.SetActive(false);
|
ContentRoot.SetActive(false);
|
||||||
@ -425,10 +454,21 @@ namespace UnityExplorer.Inspectors
|
|||||||
UIFactory.SetLayoutElement(copyButton.Component.gameObject, minHeight: 25, minWidth: 120, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(copyButton.Component.gameObject, minHeight: 25, minWidth: 120, flexibleWidth: 0);
|
||||||
copyButton.OnClick += OnCopyClicked;
|
copyButton.OnClick += OnCopyClicked;
|
||||||
|
|
||||||
assemblyText = UIFactory.CreateLabel(UIRoot, "AssemblyLabel", "not set", TextAnchor.MiddleLeft);
|
// Assembly row
|
||||||
|
|
||||||
|
GameObject asmRow = UIFactory.CreateHorizontalGroup(UIRoot, "AssemblyRow", false, false, true, true, 5, default, new(1, 1, 1, 0));
|
||||||
|
UIFactory.SetLayoutElement(asmRow, flexibleWidth: 9999, minHeight: 25);
|
||||||
|
|
||||||
|
assemblyText = UIFactory.CreateLabel(asmRow, "AssemblyLabel", "not set", TextAnchor.MiddleLeft);
|
||||||
UIFactory.SetLayoutElement(assemblyText.gameObject, minHeight: 25, flexibleWidth: 9999);
|
UIFactory.SetLayoutElement(assemblyText.gameObject, minHeight: 25, flexibleWidth: 9999);
|
||||||
|
|
||||||
ContentRoot = UIFactory.CreateVerticalGroup(UIRoot, "MemberHolder", false, false, true, true, 5, new Vector4(2, 2, 2, 2),
|
dnSpyButton = UIFactory.CreateButton(asmRow, "DnSpyButton", "View in dnSpy");
|
||||||
|
UIFactory.SetLayoutElement(dnSpyButton.GameObject, minWidth: 120, minHeight: 25);
|
||||||
|
dnSpyButton.OnClick += OnDnSpyButtonClicked;
|
||||||
|
|
||||||
|
// Content
|
||||||
|
|
||||||
|
ContentRoot = UIFactory.CreateVerticalGroup(UIRoot, "ContentRoot", false, false, true, true, 5, new Vector4(2, 2, 2, 2),
|
||||||
new Color(0.12f, 0.12f, 0.12f));
|
new Color(0.12f, 0.12f, 0.12f));
|
||||||
UIFactory.SetLayoutElement(ContentRoot, flexibleWidth: 9999, flexibleHeight: 9999);
|
UIFactory.SetLayoutElement(ContentRoot, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ namespace UnityExplorer.UI
|
|||||||
|
|
||||||
private static void ConstructUI()
|
private static void ConstructUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
popupLabel = UIFactory.CreateLabel(UIManager.UIRoot, "ClipboardNotification", "", TextAnchor.MiddleCenter);
|
popupLabel = UIFactory.CreateLabel(UIManager.UIRoot, "ClipboardNotification", "", TextAnchor.MiddleCenter);
|
||||||
popupLabel.rectTransform.sizeDelta = new(500, 100);
|
popupLabel.rectTransform.sizeDelta = new(500, 100);
|
||||||
popupLabel.gameObject.AddComponent<Outline>();
|
popupLabel.gameObject.AddComponent<Outline>();
|
||||||
|
Loading…
Reference in New Issue
Block a user