mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-04 00:23:31 +08:00
starting reflection inspector filters, some fixes
This commit is contained in:
parent
bc113e9093
commit
eedb7dd76f
@ -17,8 +17,8 @@ namespace UnityExplorer.Console.Lexer
|
|||||||
|
|
||||||
public override bool IsImplicitMatch(CSharpLexer lexer)
|
public override bool IsImplicitMatch(CSharpLexer lexer)
|
||||||
{
|
{
|
||||||
if (!char.IsWhiteSpace(lexer.Previous) ||
|
if (!char.IsWhiteSpace(lexer.Previous) &&
|
||||||
lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
|
!lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public static bool ShowMenu
|
public static bool ShowMenu
|
||||||
{
|
{
|
||||||
get => m_showMenu;
|
get => s_showMenu;
|
||||||
set => SetShowMenu(value);
|
set => SetShowMenu(value);
|
||||||
}
|
}
|
||||||
public static bool m_showMenu;
|
public static bool s_showMenu;
|
||||||
|
|
||||||
private static bool s_doneUIInit;
|
private static bool s_doneUIInit;
|
||||||
private static float s_timeSinceStartup;
|
private static float s_timeSinceStartup;
|
||||||
@ -100,13 +100,13 @@ namespace UnityExplorer
|
|||||||
#if CPP
|
#if CPP
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Application.add_logMessageReceived(new Action<string, string, LogType>(LogCallback));
|
Application.add_logMessageReceived(new Action<string, string, LogType>(OnUnityLog));
|
||||||
SceneManager.add_sceneLoaded(new Action<Scene, LoadSceneMode>((Scene a, LoadSceneMode b) => { OnSceneLoaded(); }));
|
SceneManager.add_sceneLoaded(new Action<Scene, LoadSceneMode>((Scene a, LoadSceneMode b) => { OnSceneLoaded(); }));
|
||||||
SceneManager.add_activeSceneChanged(new Action<Scene, Scene>((Scene a, Scene b) => { OnSceneLoaded(); }));
|
SceneManager.add_activeSceneChanged(new Action<Scene, Scene>((Scene a, Scene b) => { OnSceneLoaded(); }));
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
#else
|
#else
|
||||||
Application.logMessageReceived += LogCallback;
|
Application.logMessageReceived += OnUnityLog;
|
||||||
SceneManager.sceneLoaded += (Scene a, LoadSceneMode b) => { OnSceneLoaded(); };
|
SceneManager.sceneLoaded += (Scene a, LoadSceneMode b) => { OnSceneLoaded(); };
|
||||||
SceneManager.activeSceneChanged += (Scene a, Scene b) => { OnSceneLoaded(); };
|
SceneManager.activeSceneChanged += (Scene a, Scene b) => { OnSceneLoaded(); };
|
||||||
#endif
|
#endif
|
||||||
@ -119,7 +119,7 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
private static void SetShowMenu(bool show)
|
private static void SetShowMenu(bool show)
|
||||||
{
|
{
|
||||||
m_showMenu = show;
|
s_showMenu = show;
|
||||||
|
|
||||||
if (UIManager.CanvasRoot)
|
if (UIManager.CanvasRoot)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ namespace UnityExplorer
|
|||||||
ForceUnlockCursor.UpdateCursorControl();
|
ForceUnlockCursor.UpdateCursorControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogCallback(string message, string stackTrace, LogType type)
|
private void OnUnityLog(string message, string stackTrace, LogType type)
|
||||||
{
|
{
|
||||||
if (!DebugConsole.LogUnity)
|
if (!DebugConsole.LogUnity)
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#if ML
|
#if ML
|
||||||
|
using System;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using UnityExplorer.UI.Modules;
|
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,14 @@ namespace UnityExplorer.Helpers
|
|||||||
if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem."))
|
if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem."))
|
||||||
return ilObject.GetType();
|
return ilObject.GetType();
|
||||||
|
|
||||||
var getType = Type.GetType(ilObject.GetIl2CppType().AssemblyQualifiedName);
|
var il2cppType = ilObject.GetIl2CppType();
|
||||||
|
|
||||||
|
// check if type is injected
|
||||||
|
IntPtr classPtr = il2cpp_object_get_class(ilObject.Pointer);
|
||||||
|
if (RuntimeSpecificsStore.IsInjected(classPtr))
|
||||||
|
return GetTypeByName(il2cppType.FullName);
|
||||||
|
|
||||||
|
var getType = Type.GetType(il2cppType.AssemblyQualifiedName);
|
||||||
|
|
||||||
if (getType != null)
|
if (getType != null)
|
||||||
return getType;
|
return getType;
|
||||||
|
@ -123,6 +123,7 @@ namespace UnityExplorer.Inspectors
|
|||||||
tabGroupObj.AddComponent<Mask>();
|
tabGroupObj.AddComponent<Mask>();
|
||||||
|
|
||||||
var targetButtonObj = UIFactory.CreateButton(tabGroupObj);
|
var targetButtonObj = UIFactory.CreateButton(tabGroupObj);
|
||||||
|
targetButtonObj.AddComponent<Mask>();
|
||||||
var targetButtonLayout = targetButtonObj.AddComponent<LayoutElement>();
|
var targetButtonLayout = targetButtonObj.AddComponent<LayoutElement>();
|
||||||
targetButtonLayout.minWidth = 165;
|
targetButtonLayout.minWidth = 165;
|
||||||
targetButtonLayout.flexibleWidth = 0;
|
targetButtonLayout.flexibleWidth = 0;
|
||||||
|
@ -105,14 +105,14 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
public void SetInspectorTab(InspectorBase inspector)
|
public void SetInspectorTab(InspectorBase inspector)
|
||||||
{
|
{
|
||||||
|
MainMenu.Instance.SetPage(HomePage.Instance);
|
||||||
|
|
||||||
if (m_activeInspector == inspector)
|
if (m_activeInspector == inspector)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UnsetInspectorTab();
|
UnsetInspectorTab();
|
||||||
|
|
||||||
MainMenu.Instance.SetPage(HomePage.Instance);
|
|
||||||
m_activeInspector = inspector;
|
m_activeInspector = inspector;
|
||||||
|
|
||||||
inspector.SetActive();
|
inspector.SetActive();
|
||||||
|
|
||||||
Color activeColor = new Color(0, 0.25f, 0, 1);
|
Color activeColor = new Color(0, 0.25f, 0, 1);
|
||||||
|
@ -31,6 +31,9 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
public string RichTextName => m_richTextName ?? GetRichTextName();
|
public string RichTextName => m_richTextName ?? GetRichTextName();
|
||||||
private string m_richTextName;
|
private string m_richTextName;
|
||||||
|
|
||||||
|
public string NameForFiltering => m_nameForFilter ?? (m_nameForFilter = $"{MemInfo.DeclaringType.Name}.{MemInfo.Name}".ToLower());
|
||||||
|
private string m_nameForFilter;
|
||||||
|
|
||||||
public override bool CanWrite => m_canWrite ?? GetCanWrite();
|
public override bool CanWrite => m_canWrite ?? GetCanWrite();
|
||||||
private bool? m_canWrite;
|
private bool? m_canWrite;
|
||||||
|
|
||||||
|
@ -83,6 +83,8 @@ namespace UnityExplorer.Inspectors
|
|||||||
set => m_content = value;
|
set => m_content = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Text m_nameFilterText;
|
||||||
|
|
||||||
internal PageHandler m_pageHandler;
|
internal PageHandler m_pageHandler;
|
||||||
internal SliderScrollbar m_sliderScroller;
|
internal SliderScrollbar m_sliderScroller;
|
||||||
internal GameObject m_scrollContent;
|
internal GameObject m_scrollContent;
|
||||||
@ -100,13 +102,13 @@ namespace UnityExplorer.Inspectors
|
|||||||
else
|
else
|
||||||
m_targetType = ReflectionHelpers.GetActualType(target);
|
m_targetType = ReflectionHelpers.GetActualType(target);
|
||||||
|
|
||||||
m_targetTypeShortName = m_targetType.Name;
|
m_targetTypeShortName = UISyntaxHighlight.ParseFullSyntax(m_targetType, false);
|
||||||
|
|
||||||
ConstructUI();
|
ConstructUI();
|
||||||
|
|
||||||
CacheMembers(m_targetType);
|
CacheMembers(m_targetType);
|
||||||
|
|
||||||
RefreshDisplay();
|
FilterMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
@ -123,6 +125,19 @@ namespace UnityExplorer.Inspectors
|
|||||||
ActiveInstance = null;
|
ActiveInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Destroy()
|
||||||
|
{
|
||||||
|
base.Destroy();
|
||||||
|
|
||||||
|
if (this.Content)
|
||||||
|
GameObject.Destroy(this.Content);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPageTurned()
|
||||||
|
{
|
||||||
|
RefreshDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -148,24 +163,30 @@ namespace UnityExplorer.Inspectors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Destroy()
|
public void FilterMembers(string nameFilter = null)
|
||||||
{
|
{
|
||||||
base.Destroy();
|
var list = new List<CacheMember>();
|
||||||
|
|
||||||
if (this.Content)
|
nameFilter = nameFilter?.ToLower() ?? m_nameFilterText.text.ToLower();
|
||||||
GameObject.Destroy(this.Content);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPageTurned()
|
foreach (var mem in m_allMembers)
|
||||||
{
|
{
|
||||||
RefreshDisplay();
|
// name filter
|
||||||
|
if (!string.IsNullOrEmpty(nameFilter) && !mem.NameForFiltering.Contains(nameFilter))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
list.Add(mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_membersFiltered == null || m_membersFiltered.Length != list.Count)
|
||||||
|
{
|
||||||
|
m_membersFiltered = list.ToArray();
|
||||||
|
RefreshDisplay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshDisplay()
|
public void RefreshDisplay()
|
||||||
{
|
{
|
||||||
// temp because not doing filtering yet
|
|
||||||
m_membersFiltered = m_allMembers;
|
|
||||||
|
|
||||||
var members = m_membersFiltered;
|
var members = m_membersFiltered;
|
||||||
m_pageHandler.ListCount = members.Length;
|
m_pageHandler.ListCount = members.Length;
|
||||||
|
|
||||||
@ -360,65 +381,99 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
ConstructTopArea();
|
ConstructTopArea();
|
||||||
|
|
||||||
ConstructFilterArea();
|
|
||||||
|
|
||||||
ConstructMemberList();
|
ConstructMemberList();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ConstructTopArea()
|
internal void ConstructTopArea()
|
||||||
{
|
{
|
||||||
var typeRowObj = UIFactory.CreateHorizontalGroup(Content, new Color(1, 1, 1, 0));
|
var topGroupObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
|
||||||
var typeRowGroup = typeRowObj.GetComponent<HorizontalLayoutGroup>();
|
var topGroup = topGroupObj.GetComponent<VerticalLayoutGroup>();
|
||||||
typeRowGroup.childForceExpandWidth = true;
|
topGroup.childForceExpandWidth = true;
|
||||||
typeRowGroup.childForceExpandHeight = true;
|
topGroup.childForceExpandHeight = true;
|
||||||
typeRowGroup.childControlHeight = true;
|
topGroup.childControlWidth = true;
|
||||||
typeRowGroup.childControlWidth = true;
|
topGroup.childControlHeight = true;
|
||||||
var typeRowLayout = typeRowObj.AddComponent<LayoutElement>();
|
topGroup.spacing = 8;
|
||||||
typeRowLayout.minHeight = 25;
|
topGroup.padding.left = 4;
|
||||||
typeRowLayout.flexibleHeight = 0;
|
topGroup.padding.right = 4;
|
||||||
typeRowLayout.minWidth = 200;
|
|
||||||
typeRowLayout.flexibleWidth = 5000;
|
|
||||||
|
|
||||||
var typeLabel = UIFactory.CreateLabel(typeRowObj, TextAnchor.MiddleLeft);
|
var nameRowObj = UIFactory.CreateHorizontalGroup(topGroupObj, new Color(1, 1, 1, 0));
|
||||||
|
var nameRow = nameRowObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
nameRow.childForceExpandWidth = true;
|
||||||
|
nameRow.childForceExpandHeight = true;
|
||||||
|
nameRow.childControlHeight = true;
|
||||||
|
nameRow.childControlWidth = true;
|
||||||
|
nameRow.padding.top = 2;
|
||||||
|
var nameRowLayout = nameRowObj.AddComponent<LayoutElement>();
|
||||||
|
nameRowLayout.minHeight = 25;
|
||||||
|
nameRowLayout.flexibleHeight = 0;
|
||||||
|
nameRowLayout.minWidth = 200;
|
||||||
|
nameRowLayout.flexibleWidth = 5000;
|
||||||
|
|
||||||
|
var typeLabel = UIFactory.CreateLabel(nameRowObj, TextAnchor.MiddleLeft);
|
||||||
var typeLabelText = typeLabel.GetComponent<Text>();
|
var typeLabelText = typeLabel.GetComponent<Text>();
|
||||||
typeLabelText.text = "Type:";
|
typeLabelText.text = "Type:";
|
||||||
typeLabelText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
typeLabelText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
var typeLabelTextLayout = typeLabel.AddComponent<LayoutElement>();
|
var typeLabelTextLayout = typeLabel.AddComponent<LayoutElement>();
|
||||||
typeLabelTextLayout.minWidth = 60;
|
typeLabelTextLayout.minWidth = 40;
|
||||||
typeLabelTextLayout.flexibleWidth = 0;
|
typeLabelTextLayout.flexibleWidth = 0;
|
||||||
typeLabelTextLayout.minHeight = 25;
|
typeLabelTextLayout.minHeight = 25;
|
||||||
|
|
||||||
var typeLabelInputObj = UIFactory.CreateInputField(typeRowObj);
|
var typeDisplayObj = UIFactory.CreateLabel(nameRowObj, TextAnchor.MiddleLeft);
|
||||||
var typeLabelInput = typeLabelInputObj.GetComponent<InputField>();
|
var typeDisplayText = typeDisplayObj.GetComponent<Text>();
|
||||||
typeLabelInput.readOnly = true;
|
typeDisplayText.text = UISyntaxHighlight.ParseFullSyntax(m_targetType, true);
|
||||||
var typeLabelLayout = typeLabelInputObj.AddComponent<LayoutElement>();
|
var typeDisplayLayout = typeDisplayObj.AddComponent<LayoutElement>();
|
||||||
typeLabelLayout.minWidth = 150;
|
typeDisplayLayout.minHeight = 25;
|
||||||
typeLabelLayout.flexibleWidth = 5000;
|
typeDisplayLayout.flexibleWidth = 5000;
|
||||||
|
|
||||||
typeLabelInput.text = UISyntaxHighlight.ParseFullSyntax(m_targetType, true);
|
|
||||||
|
|
||||||
// Helper tools
|
// Helper tools
|
||||||
|
|
||||||
if (this is InstanceInspector instanceInspector)
|
if (this is InstanceInspector)
|
||||||
{
|
{
|
||||||
instanceInspector.ConstructInstanceHelpers(Content);
|
(this as InstanceInspector).ConstructInstanceHelpers(topGroupObj);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal void ConstructFilterArea()
|
// Filters
|
||||||
{
|
|
||||||
var filterAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
|
var filterAreaObj = UIFactory.CreateVerticalGroup(topGroupObj, new Color(1,1,1,0));
|
||||||
var filterLayout = filterAreaObj.AddComponent<LayoutElement>();
|
var filterLayout = filterAreaObj.AddComponent<LayoutElement>();
|
||||||
filterLayout.minHeight = 25;
|
filterLayout.minHeight = 60;
|
||||||
var filterGroup = filterAreaObj.GetComponent<VerticalLayoutGroup>();
|
var filterGroup = filterAreaObj.GetComponent<VerticalLayoutGroup>();
|
||||||
filterGroup.childForceExpandWidth = true;
|
filterGroup.childForceExpandWidth = true;
|
||||||
filterGroup.childForceExpandHeight = false;
|
filterGroup.childForceExpandHeight = false;
|
||||||
filterGroup.childControlWidth = true;
|
filterGroup.childControlWidth = true;
|
||||||
filterGroup.childControlHeight = true;
|
filterGroup.childControlHeight = true;
|
||||||
|
filterGroup.spacing = 4;
|
||||||
|
|
||||||
// name filter
|
// name filter
|
||||||
|
|
||||||
|
var nameFilterRowObj = UIFactory.CreateHorizontalGroup(filterAreaObj, new Color(1, 1, 1, 0));
|
||||||
|
var nameFilterGroup = nameFilterRowObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
nameFilterGroup.childForceExpandHeight = false;
|
||||||
|
nameFilterGroup.childForceExpandWidth = false;
|
||||||
|
nameFilterGroup.childControlWidth = true;
|
||||||
|
nameFilterGroup.childControlHeight = true;
|
||||||
|
nameFilterGroup.spacing = 5;
|
||||||
|
var nameFilterLayout = nameFilterRowObj.AddComponent<LayoutElement>();
|
||||||
|
nameFilterLayout.minHeight = 25;
|
||||||
|
nameFilterLayout.flexibleHeight = 0;
|
||||||
|
nameFilterLayout.flexibleWidth = 5000;
|
||||||
|
|
||||||
|
var nameLabelObj = UIFactory.CreateLabel(nameFilterRowObj, TextAnchor.MiddleLeft);
|
||||||
|
var nameLabelLayout = nameLabelObj.AddComponent<LayoutElement>();
|
||||||
|
nameLabelLayout.minWidth = 130;
|
||||||
|
nameLabelLayout.minHeight = 25;
|
||||||
|
nameLabelLayout.flexibleWidth = 0;
|
||||||
|
var nameLabelText = nameLabelObj.GetComponent<Text>();
|
||||||
|
nameLabelText.text = "Name contains:";
|
||||||
|
|
||||||
|
var nameInputObj = UIFactory.CreateInputField(nameFilterRowObj, 14, (int)TextAnchor.MiddleLeft, (int)HorizontalWrapMode.Overflow);
|
||||||
|
var nameInputLayout = nameInputObj.AddComponent<LayoutElement>();
|
||||||
|
nameInputLayout.flexibleWidth = 5000;
|
||||||
|
nameInputLayout.minWidth = 100;
|
||||||
|
nameInputLayout.minHeight = 25;
|
||||||
|
var nameInput = nameInputObj.GetComponent<InputField>();
|
||||||
|
nameInput.onValueChanged.AddListener(new Action<string>((string val) => { FilterMembers(val); }));
|
||||||
|
m_nameFilterText = nameInput.textComponent;
|
||||||
|
|
||||||
// membertype filter
|
// membertype filter
|
||||||
|
|
||||||
@ -426,9 +481,9 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
// Instance filters
|
// Instance filters
|
||||||
|
|
||||||
if (this is InstanceInspector instanceInspector)
|
if (this is InstanceInspector)
|
||||||
{
|
{
|
||||||
instanceInspector.ConstructInstanceFilters(filterAreaObj);
|
(this as InstanceInspector).ConstructInstanceFilters(filterAreaObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ namespace UnityExplorer.Inspectors
|
|||||||
private int m_lastCount;
|
private int m_lastCount;
|
||||||
|
|
||||||
private Dropdown m_sceneDropdown;
|
private Dropdown m_sceneDropdown;
|
||||||
|
private Text m_sceneDropdownText;
|
||||||
private Text m_scenePathText;
|
private Text m_scenePathText;
|
||||||
private GameObject m_mainInspectBtn;
|
private GameObject m_mainInspectBtn;
|
||||||
private GameObject m_backButtonObj;
|
private GameObject m_backButtonObj;
|
||||||
@ -135,9 +136,9 @@ namespace UnityExplorer.Inspectors
|
|||||||
m_sceneDropdown.options.Add(new Dropdown.OptionData { text = scene });
|
m_sceneDropdown.options.Add(new Dropdown.OptionData { text = scene });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!names.Contains(m_sceneDropdown.itemText.text))
|
if (!names.Contains(m_sceneDropdownText.text))
|
||||||
{
|
{
|
||||||
m_sceneDropdown.transform.Find("Label").GetComponent<Text>().text = names[0];
|
m_sceneDropdownText.text = names[0];
|
||||||
SetTargetScene(handles[0]);
|
SetTargetScene(handles[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,6 +318,8 @@ namespace UnityExplorer.Inspectors
|
|||||||
dropdownLayout.minWidth = 320;
|
dropdownLayout.minWidth = 320;
|
||||||
dropdownLayout.flexibleWidth = 2;
|
dropdownLayout.flexibleWidth = 2;
|
||||||
|
|
||||||
|
m_sceneDropdownText = m_sceneDropdown.transform.Find("Label").GetComponent<Text>();
|
||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
m_sceneDropdown.onValueChanged.AddListener(new Action<int>((int val) => { SetSceneFromDropdown(val); }));
|
m_sceneDropdown.onValueChanged.AddListener(new Action<int>((int val) => { SetSceneFromDropdown(val); }));
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user