mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2026-10-10 20:23:13 +08:00
Implemented Interactive List/Dictionary support (todo IL2CPP)
This commit is contained in:
@@ -105,7 +105,7 @@ The following helper methods are available:
|
||||
{
|
||||
if (!m_fixwanted)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(CSConsolePage.Instance.m_codeEditor.InputField.gameObject, null);
|
||||
EventSystem.current.SetSelectedGameObject(InputField.gameObject, null);
|
||||
m_fixwanted = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace UnityExplorer.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNullOrDestroyed(this object obj, bool suppressWarning = false)
|
||||
public static bool IsNullOrDestroyed(this object obj, bool suppressWarning = true)
|
||||
{
|
||||
var unityObj = obj as Object;
|
||||
if (obj == null)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
Target = target;
|
||||
|
||||
if (Target.IsNullOrDestroyed())
|
||||
if (Target.IsNullOrDestroyed(false))
|
||||
{
|
||||
Destroy();
|
||||
return;
|
||||
@@ -46,7 +46,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
if (Target.IsNullOrDestroyed())
|
||||
if (Target.IsNullOrDestroyed(false))
|
||||
{
|
||||
Destroy();
|
||||
return;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace UnityExplorer.Inspectors
|
||||
#endif
|
||||
UnityEngine.Object unityObj = obj as UnityEngine.Object;
|
||||
|
||||
if (obj.IsNullOrDestroyed())
|
||||
if (obj.IsNullOrDestroyed(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,68 @@
|
||||
//using System;
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using UnityExplorer.UI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityExplorer.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
//namespace UnityExplorer.Inspectors.Reflection
|
||||
//{
|
||||
// public class CacheEnumerated : CacheObjectBase
|
||||
// {
|
||||
// public int Index { get; set; }
|
||||
// public IList RefIList { get; set; }
|
||||
// public InteractiveEnumerable ParentEnumeration { get; set; }
|
||||
namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public class CacheEnumerated : CacheObjectBase, INestedValue
|
||||
{
|
||||
public override Type FallbackType => ParentEnumeration.m_baseEntryType;
|
||||
public override bool CanWrite => RefIList != null && ParentEnumeration.OwnerCacheObject.CanWrite;
|
||||
|
||||
// public override bool CanWrite => RefIList != null && ParentEnumeration.OwnerCacheObject.CanWrite;
|
||||
public int Index { get; set; }
|
||||
public IList RefIList { get; set; }
|
||||
public InteractiveEnumerable ParentEnumeration { get; set; }
|
||||
|
||||
// public override void SetValue()
|
||||
// {
|
||||
// RefIList[Index] = IValue.Value;
|
||||
// ParentEnumeration.Value = RefIList;
|
||||
public CacheEnumerated(int index, InteractiveEnumerable parentEnumeration, IList refIList, GameObject parentContent)
|
||||
{
|
||||
this.ParentEnumeration = parentEnumeration;
|
||||
this.Index = index;
|
||||
this.RefIList = refIList;
|
||||
this.m_parentContent = parentContent;
|
||||
}
|
||||
|
||||
// ParentEnumeration.OwnerCacheObject.SetValue();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public override void CreateIValue(object value, Type fallbackType)
|
||||
{
|
||||
IValue = InteractiveValue.Create(value, fallbackType);
|
||||
IValue.OwnerCacheObject = this;
|
||||
}
|
||||
|
||||
public override void SetValue()
|
||||
{
|
||||
RefIList[Index] = IValue.Value;
|
||||
ParentEnumeration.Value = RefIList;
|
||||
|
||||
ParentEnumeration.OwnerCacheObject.SetValue();
|
||||
}
|
||||
|
||||
public void UpdateSubcontentHeight()
|
||||
{
|
||||
ParentEnumeration.UpdateSubcontentHeight();
|
||||
}
|
||||
|
||||
internal override void ConstructUI()
|
||||
{
|
||||
base.ConstructUI();
|
||||
|
||||
var rowObj = UIFactory.CreateHorizontalGroup(m_mainContent, new Color(1, 1, 1, 0));
|
||||
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
||||
rowGroup.padding.left = 5;
|
||||
rowGroup.padding.right = 2;
|
||||
|
||||
var indexLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
||||
var indexLayout = indexLabelObj.AddComponent<LayoutElement>();
|
||||
indexLayout.minWidth = 20;
|
||||
indexLayout.flexibleWidth = 30;
|
||||
indexLayout.minHeight = 25;
|
||||
var indexText = indexLabelObj.GetComponent<Text>();
|
||||
indexText.text = this.Index + ":";
|
||||
|
||||
IValue.m_mainContentParent = rowObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,23 +7,6 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public static class CacheFactory
|
||||
{
|
||||
// Don't think I need these with new structure.
|
||||
// Will possibly need something for CacheEnumerated / InteractiveEnumeration though.
|
||||
|
||||
//public static CacheObjectBase GetCacheObject(object obj)
|
||||
//{
|
||||
// if (obj == null) return null;
|
||||
|
||||
// return GetCacheObject(obj, ReflectionHelpers.GetActualType(obj));
|
||||
//}
|
||||
|
||||
//public static CacheObjectBase GetCacheObject(object obj, Type type)
|
||||
//{
|
||||
// var ret = new CacheObjectBase();
|
||||
// ret.InitValue(obj, type);
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
public static CacheMember GetCacheObject(MemberInfo member, object declaringInstance, GameObject parentUIContent)
|
||||
{
|
||||
CacheMember ret;
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public override bool IsStatic => (MemInfo as FieldInfo).IsStatic;
|
||||
|
||||
public override Type FallbackType => (MemInfo as FieldInfo).FieldType;
|
||||
|
||||
public CacheField(FieldInfo fieldInfo, object declaringInstance) : base(fieldInfo, declaringInstance)
|
||||
{
|
||||
base.InitValue(null, fieldInfo.FieldType);
|
||||
|
||||
UpdateValue();
|
||||
CreateIValue(null, fieldInfo.FieldType);
|
||||
}
|
||||
|
||||
public override void UpdateReflection()
|
||||
|
||||
@@ -15,35 +15,34 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public abstract class CacheMember : CacheObjectBase
|
||||
{
|
||||
public override bool IsMember => true;
|
||||
|
||||
public override Type FallbackType { get; }
|
||||
|
||||
public MemberInfo MemInfo { get; set; }
|
||||
public Type DeclaringType { get; set; }
|
||||
public object DeclaringInstance { get; set; }
|
||||
|
||||
public virtual bool IsStatic { get; private set; }
|
||||
|
||||
public override bool IsMember => true;
|
||||
|
||||
public override bool HasParameters => ParamCount > 0;
|
||||
public virtual int ParamCount => m_arguments.Length;
|
||||
|
||||
public override bool HasEvaluated => m_evaluated;
|
||||
|
||||
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 string ReflectionException { get; set; }
|
||||
|
||||
public override bool CanWrite => m_canWrite ?? GetCanWrite();
|
||||
private bool? m_canWrite;
|
||||
|
||||
public string ReflectionException { get; set; }
|
||||
|
||||
public override bool HasParameters => ParamCount > 0;
|
||||
public virtual int ParamCount => m_arguments.Length;
|
||||
public override bool HasEvaluated => m_evaluated;
|
||||
public bool m_evaluated = false;
|
||||
public bool m_isEvaluating;
|
||||
public ParameterInfo[] m_arguments = new ParameterInfo[0];
|
||||
public string[] m_argumentInput = new string[0];
|
||||
|
||||
public string NameForFiltering => m_nameForFilter ?? (m_nameForFilter = $"{MemInfo.DeclaringType.Name}.{MemInfo.Name}".ToLower());
|
||||
private string m_nameForFilter;
|
||||
|
||||
public string RichTextName => m_richTextName ?? GetRichTextName();
|
||||
private string m_richTextName;
|
||||
|
||||
public CacheMember(MemberInfo memberInfo, object declaringInstance)
|
||||
{
|
||||
MemInfo = memberInfo;
|
||||
@@ -51,6 +50,14 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
DeclaringInstance = declaringInstance;
|
||||
}
|
||||
|
||||
public override void CreateIValue(object value, Type fallbackType)
|
||||
{
|
||||
IValue = InteractiveValue.Create(value, fallbackType);
|
||||
IValue.OwnerCacheObject = this;
|
||||
IValue.m_mainContentParent = this.m_rightGroup;
|
||||
IValue.m_subContentParent = this.m_subContent;
|
||||
}
|
||||
|
||||
public override void UpdateValue()
|
||||
{
|
||||
if (!HasParameters || m_isEvaluating)
|
||||
@@ -122,7 +129,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
}
|
||||
|
||||
// No input, see if there is a default value.
|
||||
if (HasDefaultValue(m_arguments[i]))
|
||||
if (m_arguments[i].IsOptional)
|
||||
{
|
||||
parsedArgs.Add(m_arguments[i].DefaultValue);
|
||||
continue;
|
||||
@@ -135,8 +142,6 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
return parsedArgs.ToArray();
|
||||
}
|
||||
|
||||
public static bool HasDefaultValue(ParameterInfo arg) => arg.DefaultValue != DBNull.Value;
|
||||
|
||||
private bool GetCanWrite()
|
||||
{
|
||||
if (MemInfo is FieldInfo fi)
|
||||
@@ -159,7 +164,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
try
|
||||
{
|
||||
var baseType = this.IValue.ValueType;
|
||||
var baseType = ReflectionHelpers.GetActualType(IValue.Value) ?? IValue.FallbackType;
|
||||
|
||||
var gArgs = baseType.GetGenericArguments();
|
||||
if (gArgs.Length < 1)
|
||||
@@ -214,13 +219,12 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
m_rightLayout.preferredWidth = valueWidth;
|
||||
}
|
||||
|
||||
internal GameObject m_leftGroup;
|
||||
internal GameObject m_rightGroup;
|
||||
internal Text m_memLabelText;
|
||||
internal RectTransform m_topRowRect;
|
||||
internal Text m_memLabelText;
|
||||
internal GameObject m_leftGroup;
|
||||
internal LayoutElement m_leftLayout;
|
||||
internal GameObject m_rightGroup;
|
||||
internal LayoutElement m_rightLayout;
|
||||
internal GameObject m_subContent;
|
||||
|
||||
internal override void ConstructUI()
|
||||
{
|
||||
@@ -292,31 +296,15 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
rightGroup.childForceExpandWidth = false;
|
||||
rightGroup.childControlHeight = true;
|
||||
rightGroup.childControlWidth = true;
|
||||
rightGroup.spacing = 4;
|
||||
rightGroup.padding.top = 2;
|
||||
rightGroup.spacing = 2;
|
||||
rightGroup.padding.top = 4;
|
||||
rightGroup.padding.bottom = 2;
|
||||
|
||||
ConstructArgInput(out GameObject argsHolder);
|
||||
|
||||
ConstructEvaluateButtons(argsHolder);
|
||||
|
||||
// subcontent
|
||||
|
||||
m_subContent = UIFactory.CreateHorizontalGroup(m_parentContent, new Color(1, 1, 1, 0));
|
||||
var subGroup = m_subContent.GetComponent<HorizontalLayoutGroup>();
|
||||
subGroup.childForceExpandWidth = true;
|
||||
subGroup.childControlWidth = true;
|
||||
var subLayout = m_subContent.AddComponent<LayoutElement>();
|
||||
subLayout.minHeight = 50;
|
||||
subLayout.flexibleHeight = 500;
|
||||
subLayout.minWidth = 125;
|
||||
subLayout.flexibleWidth = 9000;
|
||||
|
||||
m_subContent.SetActive(false);
|
||||
|
||||
// Construct InteractiveValue's actual UI
|
||||
|
||||
IValue.ConstructUI(m_rightGroup, m_subContent);
|
||||
IValue.m_mainContentParent = m_rightGroup;
|
||||
}
|
||||
|
||||
internal void ConstructArgInput(out GameObject argsHolder)
|
||||
@@ -418,13 +406,13 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
|
||||
evalButton.colors = colors;
|
||||
|
||||
var cancelButtonObj = UIFactory.CreateButton(evalGroupObj, new Color(0.6f, 0.3f, 0.3f));
|
||||
var cancelButtonObj = UIFactory.CreateButton(evalGroupObj, new Color(0.3f, 0.3f, 0.3f));
|
||||
var cancelLayout = cancelButtonObj.AddComponent<LayoutElement>();
|
||||
cancelLayout.minWidth = 100;
|
||||
cancelLayout.minHeight = 22;
|
||||
cancelLayout.flexibleWidth = 0;
|
||||
var cancelText = cancelButtonObj.GetComponentInChildren<Text>();
|
||||
cancelText.text = "Cancel";
|
||||
cancelText.text = "Close";
|
||||
|
||||
cancelButtonObj.SetActive(false);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
//private CacheObjectBase m_cachedReturnValue;
|
||||
|
||||
public override Type FallbackType => (MemInfo as MethodInfo).ReturnType;
|
||||
|
||||
public override bool HasParameters => base.HasParameters || GenericArgs.Length > 0;
|
||||
|
||||
public override bool IsStatic => (MemInfo as MethodInfo).IsStatic;
|
||||
@@ -37,12 +39,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
m_arguments = methodInfo.GetParameters();
|
||||
m_argumentInput = new string[m_arguments.Length];
|
||||
|
||||
base.InitValue(null, methodInfo.ReturnType);
|
||||
}
|
||||
|
||||
public override void UpdateValue()
|
||||
{
|
||||
base.UpdateValue();
|
||||
CreateIValue(null, methodInfo.ReturnType);
|
||||
}
|
||||
|
||||
public override void UpdateReflection()
|
||||
@@ -78,10 +75,8 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
ReflectionException = ReflectionHelpers.ExceptionToString(e);
|
||||
}
|
||||
|
||||
// todo do InitValue again for new value, in case type changed fundamentally.
|
||||
|
||||
IValue.Value = ret;
|
||||
IValue.OnValueUpdated();
|
||||
UpdateValue();
|
||||
}
|
||||
|
||||
private MethodInfo MakeGenericMethodFromInput()
|
||||
|
||||
@@ -10,7 +10,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public class CacheObjectBase
|
||||
public abstract class CacheObjectBase
|
||||
{
|
||||
public InteractiveValue IValue;
|
||||
|
||||
@@ -19,26 +19,9 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
public virtual bool IsMember => false;
|
||||
public virtual bool HasEvaluated => true;
|
||||
|
||||
// TODO
|
||||
public virtual void InitValue(object value, Type valueType)
|
||||
{
|
||||
if (valueType == null && value == null)
|
||||
{
|
||||
ExplorerCore.LogWarning("CacheObjectBase: Trying to init with no default value or valueType!");
|
||||
ExplorerCore.Log(Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
public abstract Type FallbackType { get; }
|
||||
|
||||
// temp (havent made rest of InteractiveValue classes yet, just using base class always)
|
||||
|
||||
valueType = ReflectionHelpers.GetActualType(value) ?? valueType;
|
||||
|
||||
IValue = new InteractiveValue(valueType)
|
||||
{
|
||||
OwnerCacheObject = this
|
||||
};
|
||||
UpdateValue();
|
||||
}
|
||||
public abstract void CreateIValue(object value, Type fallbackType);
|
||||
|
||||
public virtual void Enable()
|
||||
{
|
||||
@@ -54,11 +37,31 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
|
||||
public virtual void Disable()
|
||||
{
|
||||
m_mainContent.SetActive(false);
|
||||
m_mainContent?.SetActive(false);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
GameObject.Destroy(this.m_mainContent);
|
||||
}
|
||||
|
||||
public virtual void UpdateValue()
|
||||
{
|
||||
var value = IValue.Value;
|
||||
|
||||
// see if current value has changed types fundamentally
|
||||
var type = value == null
|
||||
? FallbackType
|
||||
: ReflectionHelpers.GetActualType(value);
|
||||
var ivalueType = InteractiveValue.GetIValueForType(type);
|
||||
|
||||
if (ivalueType != IValue.IValueType)
|
||||
{
|
||||
IValue.OnDestroy();
|
||||
CreateIValue(value, FallbackType);
|
||||
m_subContent.SetActive(false);
|
||||
}
|
||||
|
||||
IValue.OnValueUpdated();
|
||||
}
|
||||
|
||||
@@ -68,7 +71,9 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
|
||||
internal bool m_constructedUI;
|
||||
internal GameObject m_parentContent;
|
||||
internal RectTransform m_mainRect;
|
||||
internal GameObject m_mainContent;
|
||||
internal GameObject m_subContent;
|
||||
|
||||
// Make base UI holder for CacheObject, this doesnt actually display anything.
|
||||
internal virtual void ConstructUI()
|
||||
@@ -76,16 +81,36 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
m_constructedUI = true;
|
||||
|
||||
m_mainContent = UIFactory.CreateVerticalGroup(m_parentContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
var rowGroup = m_mainContent.GetComponent<VerticalLayoutGroup>();
|
||||
rowGroup.childForceExpandWidth = true;
|
||||
rowGroup.childControlWidth = true;
|
||||
rowGroup.childForceExpandHeight = false;
|
||||
rowGroup.childControlHeight = true;
|
||||
var rowLayout = m_mainContent.AddComponent<LayoutElement>();
|
||||
rowLayout.minHeight = 25;
|
||||
rowLayout.flexibleHeight = 500;
|
||||
rowLayout.minWidth = 200;
|
||||
rowLayout.flexibleWidth = 5000;
|
||||
m_mainContent.name = "CacheObjectBase.MainContent";
|
||||
m_mainRect = m_mainContent.GetComponent<RectTransform>();
|
||||
m_mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);
|
||||
var mainGroup = m_mainContent.GetComponent<VerticalLayoutGroup>();
|
||||
mainGroup.childForceExpandWidth = true;
|
||||
mainGroup.childControlWidth = true;
|
||||
mainGroup.childForceExpandHeight = true;
|
||||
mainGroup.childControlHeight = true;
|
||||
var mainLayout = m_mainContent.AddComponent<LayoutElement>();
|
||||
mainLayout.minHeight = 25;
|
||||
mainLayout.flexibleHeight = 9999;
|
||||
mainLayout.minWidth = 200;
|
||||
mainLayout.flexibleWidth = 5000;
|
||||
|
||||
// subcontent
|
||||
|
||||
m_subContent = UIFactory.CreateVerticalGroup(m_mainContent, new Color(0.085f, 0.085f, 0.085f));
|
||||
m_subContent.name = "CacheObjectBase.SubContent";
|
||||
var subGroup = m_subContent.GetComponent<VerticalLayoutGroup>();
|
||||
subGroup.childForceExpandWidth = true;
|
||||
subGroup.childForceExpandHeight = false;
|
||||
var subLayout = m_subContent.AddComponent<LayoutElement>();
|
||||
subLayout.minHeight = 30;
|
||||
subLayout.flexibleHeight = 9999;
|
||||
subLayout.minWidth = 125;
|
||||
subLayout.flexibleWidth = 9000;
|
||||
|
||||
m_subContent.SetActive(false);
|
||||
|
||||
IValue.m_subContentParent = m_subContent;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityExplorer.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public enum PairTypes
|
||||
{
|
||||
Key,
|
||||
Value
|
||||
}
|
||||
|
||||
public class CachePaired : CacheObjectBase, INestedValue
|
||||
{
|
||||
public override Type FallbackType => PairType == PairTypes.Key
|
||||
? ParentDictionary.m_typeOfKeys
|
||||
: ParentDictionary.m_typeofValues;
|
||||
|
||||
public override bool CanWrite => false; // todo?
|
||||
|
||||
public PairTypes PairType;
|
||||
public int Index { get; private set; }
|
||||
public InteractiveDictionary ParentDictionary { get; private set; }
|
||||
internal IDictionary RefIDIct;
|
||||
|
||||
public CachePaired(int index, InteractiveDictionary parentDict, IDictionary refIDict, PairTypes pairType, GameObject parentContent)
|
||||
{
|
||||
Index = index;
|
||||
ParentDictionary = parentDict;
|
||||
RefIDIct = refIDict;
|
||||
this.PairType = pairType;
|
||||
this.m_parentContent = parentContent;
|
||||
}
|
||||
|
||||
public override void CreateIValue(object value, Type fallbackType)
|
||||
{
|
||||
IValue = InteractiveValue.Create(value, fallbackType);
|
||||
IValue.OwnerCacheObject = this;
|
||||
}
|
||||
|
||||
public void UpdateSubcontentHeight()
|
||||
{
|
||||
ParentDictionary.UpdateSubcontentHeight();
|
||||
}
|
||||
|
||||
#region UI CONSTRUCTION
|
||||
|
||||
internal override void ConstructUI()
|
||||
{
|
||||
base.ConstructUI();
|
||||
|
||||
var rowObj = UIFactory.CreateHorizontalGroup(m_mainContent, new Color(1, 1, 1, 0));
|
||||
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
|
||||
rowGroup.padding.left = 5;
|
||||
rowGroup.padding.right = 2;
|
||||
|
||||
var indexLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
|
||||
var indexLayout = indexLabelObj.AddComponent<LayoutElement>();
|
||||
indexLayout.minWidth = 80;
|
||||
indexLayout.flexibleWidth = 30;
|
||||
indexLayout.minHeight = 25;
|
||||
var indexText = indexLabelObj.GetComponent<Text>();
|
||||
indexText.text = $"{this.PairType} {this.Index}:";
|
||||
|
||||
IValue.m_mainContentParent = rowObj;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public class CacheProperty : CacheMember
|
||||
{
|
||||
public override Type FallbackType => (MemInfo as PropertyInfo).PropertyType;
|
||||
|
||||
public override bool IsStatic => (MemInfo as PropertyInfo).GetAccessors(true)[0].IsStatic;
|
||||
|
||||
public CacheProperty(PropertyInfo propertyInfo, object declaringInstance) : base(propertyInfo, declaringInstance)
|
||||
@@ -17,9 +19,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
||||
this.m_arguments = propertyInfo.GetIndexParameters();
|
||||
this.m_argumentInput = new string[m_arguments.Length];
|
||||
|
||||
base.InitValue(null, propertyInfo.PropertyType);
|
||||
|
||||
UpdateValue();
|
||||
CreateIValue(null, propertyInfo.PropertyType);
|
||||
}
|
||||
|
||||
public override void UpdateReflection()
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityExplorer.Inspectors.Reflection
|
||||
{
|
||||
public interface INestedValue
|
||||
{
|
||||
void UpdateSubcontentHeight();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -13,10 +13,6 @@ using UnityExplorer.Config;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
{
|
||||
// TODO:
|
||||
// - Filters
|
||||
// - Helper tools for Target object (for UnityEngine.Objects, Components, Textures, and maybe a general ToString helper)
|
||||
|
||||
public class ReflectionInspector : InspectorBase
|
||||
{
|
||||
#region STATIC
|
||||
@@ -95,8 +91,6 @@ namespace UnityExplorer.Inspectors
|
||||
internal bool m_widthUpdateWanted;
|
||||
internal bool m_widthUpdateWaiting;
|
||||
|
||||
// Ctor
|
||||
|
||||
public ReflectionInspector(object target) : base(target)
|
||||
{
|
||||
if (this is StaticInspector)
|
||||
@@ -113,8 +107,6 @@ namespace UnityExplorer.Inspectors
|
||||
FilterMembers();
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
public override void SetActive()
|
||||
{
|
||||
base.SetActive();
|
||||
@@ -310,14 +302,14 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
try
|
||||
{
|
||||
//ExplorerCore.Log($"Trying to cache member {sig}...");
|
||||
//ExplorerCore.Log(member.DeclaringType.FullName + "." + member.Name);
|
||||
|
||||
// make sure member type is Field, Method or Property (4 / 8 / 16)
|
||||
int m = (int)member.MemberType;
|
||||
if (m < 4 || m > 16)
|
||||
continue;
|
||||
|
||||
//ExplorerCore.Log($"Trying to cache member {sig}...");
|
||||
//ExplorerCore.Log(member.DeclaringType.FullName + "." + member.Name);
|
||||
|
||||
var pi = member as PropertyInfo;
|
||||
var mi = member as MethodInfo;
|
||||
|
||||
@@ -338,28 +330,20 @@ namespace UnityExplorer.Inspectors
|
||||
continue;
|
||||
|
||||
if (mi != null)
|
||||
{
|
||||
AppendParams(mi.GetParameters());
|
||||
}
|
||||
else if (pi != null)
|
||||
{
|
||||
AppendParams(pi.GetIndexParameters());
|
||||
}
|
||||
|
||||
void AppendParams(ParameterInfo[] _args)
|
||||
{
|
||||
sig += " (";
|
||||
foreach (var param in _args)
|
||||
{
|
||||
sig += $"{param.ParameterType.Name} {param.Name}, ";
|
||||
}
|
||||
sig += ")";
|
||||
}
|
||||
|
||||
if (cachedSigs.Contains(sig))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -385,10 +369,18 @@ namespace UnityExplorer.Inspectors
|
||||
}
|
||||
}
|
||||
|
||||
var typeList = types.ToList();
|
||||
|
||||
var sorted = new List<CacheMember>();
|
||||
sorted.AddRange(list.Where(x => x is CacheMethod));
|
||||
sorted.AddRange(list.Where(x => x is CacheProperty));
|
||||
sorted.AddRange(list.Where(x => x is CacheField));
|
||||
sorted.AddRange(list.Where(it => it is CacheMethod)
|
||||
.OrderBy(it => typeList.IndexOf(it.DeclaringType))
|
||||
.ThenBy(it => it.NameForFiltering));
|
||||
sorted.AddRange(list.Where(it => it is CacheProperty)
|
||||
.OrderBy(it => typeList.IndexOf(it.DeclaringType))
|
||||
.ThenBy(it => it.NameForFiltering));
|
||||
sorted.AddRange(list.Where(it => it is CacheField)
|
||||
.OrderBy(it => typeList.IndexOf(it.DeclaringType))
|
||||
.ThenBy(it => it.NameForFiltering));
|
||||
|
||||
m_allMembers = sorted.ToArray();
|
||||
|
||||
@@ -623,6 +615,7 @@ namespace UnityExplorer.Inspectors
|
||||
scrollGroup.spacing = 3;
|
||||
scrollGroup.padding.left = 0;
|
||||
scrollGroup.padding.right = 0;
|
||||
scrollGroup.childForceExpandHeight = true;
|
||||
|
||||
m_pageHandler = new PageHandler(m_sliderScroller);
|
||||
m_pageHandler.ConstructUI(Content);
|
||||
|
||||
+49
-5
@@ -26,27 +26,71 @@ namespace UnityExplorer.Tests
|
||||
public static TestClass Instance => m_instance ?? (m_instance = new TestClass());
|
||||
private static TestClass m_instance;
|
||||
|
||||
public static bool ReadSetOnlyProperty => m_setOnlyProperty;
|
||||
public Dictionary<string, List<string>> AComboTest = new Dictionary<string, List<string>>
|
||||
{
|
||||
{
|
||||
"key",
|
||||
new List<string>
|
||||
{
|
||||
"1",
|
||||
"2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public object AmbigObject;
|
||||
|
||||
public List<List<List<string>>> ANestedNestedList = new List<List<List<string>>>
|
||||
{
|
||||
new List<List<string>>
|
||||
{
|
||||
new List<string>
|
||||
{
|
||||
"one",
|
||||
"two",
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"three",
|
||||
"four"
|
||||
}
|
||||
},
|
||||
new List<List<string>>
|
||||
{
|
||||
new List<string>
|
||||
{
|
||||
"five",
|
||||
"six"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static bool SetOnlyProperty
|
||||
{
|
||||
set => m_setOnlyProperty = value;
|
||||
}
|
||||
private static bool m_setOnlyProperty;
|
||||
public static bool ReadSetOnlyProperty => m_setOnlyProperty;
|
||||
|
||||
public Texture TestTexture;
|
||||
public static Sprite TestSprite;
|
||||
|
||||
public static int StaticProperty => 5;
|
||||
public static int StaticField = 5;
|
||||
public int NonStaticField;
|
||||
|
||||
#if CPP
|
||||
public static Il2CppSystem.Collections.Generic.HashSet<string> ILHashSetTest;
|
||||
#endif
|
||||
|
||||
public TestClass()
|
||||
{
|
||||
int a = 0;
|
||||
foreach (var list in ANestedNestedList)
|
||||
{
|
||||
foreach (var list2 in list)
|
||||
{
|
||||
for (int i = 0; i < 33; i++)
|
||||
list2.Add(a++.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#if CPP
|
||||
TestTexture = UIManager.MakeSolidTexture(Color.white, 200, 200);
|
||||
TestTexture.name = "TestTexture";
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace UnityExplorer.UI.Shared
|
||||
|
||||
public event Action OnPageChanged;
|
||||
|
||||
private SliderScrollbar m_scrollbar;
|
||||
private readonly SliderScrollbar m_scrollbar;
|
||||
|
||||
// For now this is just set when the PageHandler is created, based on config.
|
||||
// At some point I might make it possible to change this after creation again.
|
||||
@@ -147,7 +147,9 @@ namespace UnityExplorer.UI.Shared
|
||||
}
|
||||
if (didTurn)
|
||||
{
|
||||
m_scrollbar.m_scrollbar.value = 1;
|
||||
if (m_scrollbar != null)
|
||||
m_scrollbar.m_scrollbar.value = 1;
|
||||
|
||||
OnPageChanged?.Invoke();
|
||||
RefreshUI();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//using UnityEngine;
|
||||
//using System.Collections;
|
||||
//using UnityEngine.UI;
|
||||
//using System;
|
||||
//using UnityEngine.EventSystems;
|
||||
|
||||
|
||||
/////////////// kinda works, not really
|
||||
|
||||
|
||||
//public class ScrollRectEx : ScrollRect, IEventSystemHandler
|
||||
//{
|
||||
// internal SliderScrollbar sliderScrollbar;
|
||||
|
||||
// private bool ShouldRouteToParent(PointerEventData data)
|
||||
// => !sliderScrollbar.IsActive
|
||||
// || sliderScrollbar.m_slider.value < 0.001f && data.delta.y > 0
|
||||
// || sliderScrollbar.m_slider.value == 1f && data.delta.y < 0;
|
||||
|
||||
// private void DoForParents<T>(Action<T> action) where T : IEventSystemHandler
|
||||
// {
|
||||
// Transform parent = transform.parent;
|
||||
// while (parent != null)
|
||||
// {
|
||||
// foreach (var component in parent.GetComponents<Component>())
|
||||
// {
|
||||
// if (component is T)
|
||||
// action((T)(IEventSystemHandler)component);
|
||||
// }
|
||||
// parent = parent.parent;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public override void OnScroll(PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IScrollHandler>((parent) => { parent.OnScroll(data); });
|
||||
// else
|
||||
// base.OnScroll(data);
|
||||
// }
|
||||
|
||||
// public override void OnInitializePotentialDrag(PointerEventData eventData)
|
||||
// {
|
||||
// DoForParents<IInitializePotentialDragHandler>((parent) => { parent.OnInitializePotentialDrag(eventData); });
|
||||
// base.OnInitializePotentialDrag(eventData);
|
||||
// }
|
||||
|
||||
// public override void OnDrag(PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IDragHandler>((parent) => { parent.OnDrag(data); });
|
||||
// else
|
||||
// base.OnDrag(data);
|
||||
// }
|
||||
|
||||
// public override void OnBeginDrag(UnityEngine.EventSystems.PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IBeginDragHandler>((parent) => { parent.OnBeginDrag(data); });
|
||||
// else
|
||||
// base.OnBeginDrag(data);
|
||||
// }
|
||||
|
||||
// public override void OnEndDrag(UnityEngine.EventSystems.PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IEndDragHandler>((parent) => { parent.OnEndDrag(data); });
|
||||
// else
|
||||
// base.OnEndDrag(data);
|
||||
// }
|
||||
//}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user