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)
|
||||
{
|
||||
if (!char.IsWhiteSpace(lexer.Previous) ||
|
||||
lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
|
||||
if (!char.IsWhiteSpace(lexer.Previous) &&
|
||||
!lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ namespace UnityExplorer
|
||||
|
||||
public static bool ShowMenu
|
||||
{
|
||||
get => m_showMenu;
|
||||
get => s_showMenu;
|
||||
set => SetShowMenu(value);
|
||||
}
|
||||
public static bool m_showMenu;
|
||||
public static bool s_showMenu;
|
||||
|
||||
private static bool s_doneUIInit;
|
||||
private static float s_timeSinceStartup;
|
||||
@ -100,13 +100,13 @@ namespace UnityExplorer
|
||||
#if CPP
|
||||
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_activeSceneChanged(new Action<Scene, Scene>((Scene a, Scene b) => { OnSceneLoaded(); }));
|
||||
}
|
||||
catch { }
|
||||
#else
|
||||
Application.logMessageReceived += LogCallback;
|
||||
Application.logMessageReceived += OnUnityLog;
|
||||
SceneManager.sceneLoaded += (Scene a, LoadSceneMode b) => { OnSceneLoaded(); };
|
||||
SceneManager.activeSceneChanged += (Scene a, Scene b) => { OnSceneLoaded(); };
|
||||
#endif
|
||||
@ -119,7 +119,7 @@ namespace UnityExplorer
|
||||
|
||||
private static void SetShowMenu(bool show)
|
||||
{
|
||||
m_showMenu = show;
|
||||
s_showMenu = show;
|
||||
|
||||
if (UIManager.CanvasRoot)
|
||||
{
|
||||
@ -134,7 +134,7 @@ namespace UnityExplorer
|
||||
ForceUnlockCursor.UpdateCursorControl();
|
||||
}
|
||||
|
||||
private void LogCallback(string message, string stackTrace, LogType type)
|
||||
private void OnUnityLog(string message, string stackTrace, LogType type)
|
||||
{
|
||||
if (!DebugConsole.LogUnity)
|
||||
return;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#if ML
|
||||
using System;
|
||||
using MelonLoader;
|
||||
using UnityExplorer.UI.Modules;
|
||||
|
||||
namespace UnityExplorer
|
||||
{
|
||||
|
@ -83,7 +83,14 @@ namespace UnityExplorer.Helpers
|
||||
if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem."))
|
||||
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)
|
||||
return getType;
|
||||
|
@ -123,6 +123,7 @@ namespace UnityExplorer.Inspectors
|
||||
tabGroupObj.AddComponent<Mask>();
|
||||
|
||||
var targetButtonObj = UIFactory.CreateButton(tabGroupObj);
|
||||
targetButtonObj.AddComponent<Mask>();
|
||||
var targetButtonLayout = targetButtonObj.AddComponent<LayoutElement>();
|
||||
targetButtonLayout.minWidth = 165;
|
||||
targetButtonLayout.flexibleWidth = 0;
|
||||
|
@ -105,14 +105,14 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public void SetInspectorTab(InspectorBase inspector)
|
||||
{
|
||||
MainMenu.Instance.SetPage(HomePage.Instance);
|
||||
|
||||
if (m_activeInspector == inspector)
|
||||
return;
|
||||
|
||||
UnsetInspectorTab();
|
||||
|
||||
MainMenu.Instance.SetPage(HomePage.Instance);
|
||||
m_activeInspector = inspector;
|
||||
|
||||
inspector.SetActive();
|
||||
|
||||
Color activeColor = new Color(0, 0.25f, 0, 1);
|
||||
|
@ -31,6 +31,9 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
public string RichTextName => m_richTextName ?? GetRichTextName();
|
||||
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();
|
||||
private bool? m_canWrite;
|
||||
|
||||
|
@ -83,6 +83,8 @@ namespace UnityExplorer.Inspectors
|
||||
set => m_content = value;
|
||||
}
|
||||
|
||||
internal Text m_nameFilterText;
|
||||
|
||||
internal PageHandler m_pageHandler;
|
||||
internal SliderScrollbar m_sliderScroller;
|
||||
internal GameObject m_scrollContent;
|
||||
@ -100,13 +102,13 @@ namespace UnityExplorer.Inspectors
|
||||
else
|
||||
m_targetType = ReflectionHelpers.GetActualType(target);
|
||||
|
||||
m_targetTypeShortName = m_targetType.Name;
|
||||
m_targetTypeShortName = UISyntaxHighlight.ParseFullSyntax(m_targetType, false);
|
||||
|
||||
ConstructUI();
|
||||
|
||||
CacheMembers(m_targetType);
|
||||
|
||||
RefreshDisplay();
|
||||
FilterMembers();
|
||||
}
|
||||
|
||||
// Methods
|
||||
@ -123,6 +125,19 @@ namespace UnityExplorer.Inspectors
|
||||
ActiveInstance = null;
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
|
||||
if (this.Content)
|
||||
GameObject.Destroy(this.Content);
|
||||
}
|
||||
|
||||
private void OnPageTurned()
|
||||
{
|
||||
RefreshDisplay();
|
||||
}
|
||||
|
||||
public override void 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)
|
||||
GameObject.Destroy(this.Content);
|
||||
nameFilter = nameFilter?.ToLower() ?? m_nameFilterText.text.ToLower();
|
||||
|
||||
foreach (var mem in m_allMembers)
|
||||
{
|
||||
// name filter
|
||||
if (!string.IsNullOrEmpty(nameFilter) && !mem.NameForFiltering.Contains(nameFilter))
|
||||
continue;
|
||||
|
||||
list.Add(mem);
|
||||
}
|
||||
|
||||
private void OnPageTurned()
|
||||
if (m_membersFiltered == null || m_membersFiltered.Length != list.Count)
|
||||
{
|
||||
m_membersFiltered = list.ToArray();
|
||||
RefreshDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshDisplay()
|
||||
{
|
||||
// temp because not doing filtering yet
|
||||
m_membersFiltered = m_allMembers;
|
||||
|
||||
var members = m_membersFiltered;
|
||||
m_pageHandler.ListCount = members.Length;
|
||||
|
||||
@ -360,65 +381,99 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
ConstructTopArea();
|
||||
|
||||
ConstructFilterArea();
|
||||
|
||||
ConstructMemberList();
|
||||
}
|
||||
|
||||
internal void ConstructTopArea()
|
||||
{
|
||||
var typeRowObj = UIFactory.CreateHorizontalGroup(Content, new Color(1, 1, 1, 0));
|
||||
var typeRowGroup = typeRowObj.GetComponent<HorizontalLayoutGroup>();
|
||||
typeRowGroup.childForceExpandWidth = true;
|
||||
typeRowGroup.childForceExpandHeight = true;
|
||||
typeRowGroup.childControlHeight = true;
|
||||
typeRowGroup.childControlWidth = true;
|
||||
var typeRowLayout = typeRowObj.AddComponent<LayoutElement>();
|
||||
typeRowLayout.minHeight = 25;
|
||||
typeRowLayout.flexibleHeight = 0;
|
||||
typeRowLayout.minWidth = 200;
|
||||
typeRowLayout.flexibleWidth = 5000;
|
||||
var topGroupObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
|
||||
var topGroup = topGroupObj.GetComponent<VerticalLayoutGroup>();
|
||||
topGroup.childForceExpandWidth = true;
|
||||
topGroup.childForceExpandHeight = true;
|
||||
topGroup.childControlWidth = true;
|
||||
topGroup.childControlHeight = true;
|
||||
topGroup.spacing = 8;
|
||||
topGroup.padding.left = 4;
|
||||
topGroup.padding.right = 4;
|
||||
|
||||
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>();
|
||||
typeLabelText.text = "Type:";
|
||||
typeLabelText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
var typeLabelTextLayout = typeLabel.AddComponent<LayoutElement>();
|
||||
typeLabelTextLayout.minWidth = 60;
|
||||
typeLabelTextLayout.minWidth = 40;
|
||||
typeLabelTextLayout.flexibleWidth = 0;
|
||||
typeLabelTextLayout.minHeight = 25;
|
||||
|
||||
var typeLabelInputObj = UIFactory.CreateInputField(typeRowObj);
|
||||
var typeLabelInput = typeLabelInputObj.GetComponent<InputField>();
|
||||
typeLabelInput.readOnly = true;
|
||||
var typeLabelLayout = typeLabelInputObj.AddComponent<LayoutElement>();
|
||||
typeLabelLayout.minWidth = 150;
|
||||
typeLabelLayout.flexibleWidth = 5000;
|
||||
|
||||
typeLabelInput.text = UISyntaxHighlight.ParseFullSyntax(m_targetType, true);
|
||||
var typeDisplayObj = UIFactory.CreateLabel(nameRowObj, TextAnchor.MiddleLeft);
|
||||
var typeDisplayText = typeDisplayObj.GetComponent<Text>();
|
||||
typeDisplayText.text = UISyntaxHighlight.ParseFullSyntax(m_targetType, true);
|
||||
var typeDisplayLayout = typeDisplayObj.AddComponent<LayoutElement>();
|
||||
typeDisplayLayout.minHeight = 25;
|
||||
typeDisplayLayout.flexibleWidth = 5000;
|
||||
|
||||
// Helper tools
|
||||
|
||||
if (this is InstanceInspector instanceInspector)
|
||||
if (this is InstanceInspector)
|
||||
{
|
||||
instanceInspector.ConstructInstanceHelpers(Content);
|
||||
}
|
||||
(this as InstanceInspector).ConstructInstanceHelpers(topGroupObj);
|
||||
}
|
||||
|
||||
internal void ConstructFilterArea()
|
||||
{
|
||||
var filterAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
|
||||
// Filters
|
||||
|
||||
var filterAreaObj = UIFactory.CreateVerticalGroup(topGroupObj, new Color(1,1,1,0));
|
||||
var filterLayout = filterAreaObj.AddComponent<LayoutElement>();
|
||||
filterLayout.minHeight = 25;
|
||||
filterLayout.minHeight = 60;
|
||||
var filterGroup = filterAreaObj.GetComponent<VerticalLayoutGroup>();
|
||||
filterGroup.childForceExpandWidth = true;
|
||||
filterGroup.childForceExpandHeight = false;
|
||||
filterGroup.childControlWidth = true;
|
||||
filterGroup.childControlHeight = true;
|
||||
filterGroup.spacing = 4;
|
||||
|
||||
// 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
|
||||
|
||||
@ -426,9 +481,9 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// 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 Dropdown m_sceneDropdown;
|
||||
private Text m_sceneDropdownText;
|
||||
private Text m_scenePathText;
|
||||
private GameObject m_mainInspectBtn;
|
||||
private GameObject m_backButtonObj;
|
||||
@ -135,9 +136,9 @@ namespace UnityExplorer.Inspectors
|
||||
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]);
|
||||
}
|
||||
}
|
||||
@ -317,6 +318,8 @@ namespace UnityExplorer.Inspectors
|
||||
dropdownLayout.minWidth = 320;
|
||||
dropdownLayout.flexibleWidth = 2;
|
||||
|
||||
m_sceneDropdownText = m_sceneDropdown.transform.Find("Label").GetComponent<Text>();
|
||||
|
||||
#if CPP
|
||||
m_sceneDropdown.onValueChanged.AddListener(new Action<int>((int val) => { SetSceneFromDropdown(val); }));
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user