diff --git a/src/UI/Inspectors/CacheObject/CacheField.cs b/src/UI/Inspectors/CacheObject/CacheField.cs
index 285a679..9de77a3 100644
--- a/src/UI/Inspectors/CacheObject/CacheField.cs
+++ b/src/UI/Inspectors/CacheObject/CacheField.cs
@@ -10,22 +10,21 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
public FieldInfo FieldInfo { get; internal set; }
public override Type DeclaringType => FieldInfo.DeclaringType;
+ public override bool CanWrite => m_canWrite ?? (bool)(m_canWrite = !(FieldInfo.IsLiteral && !FieldInfo.IsInitOnly));
+ private bool? m_canWrite;
public override bool ShouldAutoEvaluate => true;
public override void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member)
{
base.SetInspectorOwner(inspector, member);
-
- // not constant
- CanWrite = !(FieldInfo.IsLiteral && !FieldInfo.IsInitOnly);
}
protected override void TryEvaluate()
{
try
{
- Value = FieldInfo.GetValue(this.ParentInspector.Target.TryCast(this.DeclaringType));
+ Value = FieldInfo.GetValue(this.Owner.Target.TryCast(this.DeclaringType));
}
catch (Exception ex)
{
@@ -38,7 +37,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
try
{
- FieldInfo.SetValue(FieldInfo.IsStatic ? null : ParentInspector.Target, value);
+ FieldInfo.SetValue(FieldInfo.IsStatic ? null : Owner.Target, value);
}
catch (Exception ex)
{
diff --git a/src/UI/Inspectors/CacheObject/CacheKeyValuePair.cs b/src/UI/Inspectors/CacheObject/CacheKeyValuePair.cs
new file mode 100644
index 0000000..e7641b8
--- /dev/null
+++ b/src/UI/Inspectors/CacheObject/CacheKeyValuePair.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityExplorer.UI.Inspectors.CacheObject.Views;
+using UnityExplorer.UI.Inspectors.IValues;
+using UnityExplorer.UI.Utility;
+
+namespace UnityExplorer.UI.Inspectors.CacheObject
+{
+ public class CacheKeyValuePair : CacheObjectBase
+ {
+ //public InteractiveList CurrentList { get; set; }
+
+ public int DictIndex;
+ public object DictKey;
+
+ public bool KeyInputWanted;
+ public bool InspectWanted;
+ public string KeyLabelText;
+ public string KeyInputText;
+ public string KeyInputTypeText;
+
+ public float DesiredKeyWidth;
+ public float DesiredValueWidth;
+
+ public override bool ShouldAutoEvaluate => true;
+ public override bool HasArguments => false;
+ public override bool CanWrite => false; // TODO Parent.CanWrite;
+
+ public void SetDictOwner(InteractiveDictionary dict, int index)
+ {
+ this.Owner = dict;
+ this.DictIndex = index;
+ }
+
+ public void SetKey(object key)
+ {
+ this.DictKey = key;
+ var type = key.GetActualType();
+ if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))) || type == typeof(decimal))
+ {
+ KeyInputWanted = true;
+ KeyInputText = key.ToString();
+ KeyInputTypeText = SignatureHighlighter.ParseFullType(type, false);
+ }
+ else
+ {
+ KeyInputWanted = false;
+ InspectWanted = type != typeof(bool) && !type.IsEnum;
+ KeyLabelText = ToStringUtility.ToStringWithType(key, type, true);
+ }
+ }
+
+ public override void SetCell(CacheObjectCell cell)
+ {
+ base.SetCell(cell);
+
+ var kvpCell = cell as CacheKeyValuePairCell;
+
+ kvpCell.NameLabel.text = $"{DictIndex}:";
+ kvpCell.Image.color = DictIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor;
+
+ if (KeyInputWanted)
+ {
+ kvpCell.KeyInputField.gameObject.SetActive(true);
+ kvpCell.KeyInputTypeLabel.gameObject.SetActive(true);
+ kvpCell.KeyLabel.gameObject.SetActive(false);
+ kvpCell.KeyInspectButton.Button.gameObject.SetActive(false);
+
+ kvpCell.KeyInputField.text = KeyInputText;
+ kvpCell.KeyInputTypeLabel.text = KeyInputTypeText;
+ }
+ else
+ {
+ kvpCell.KeyInputField.gameObject.SetActive(false);
+ kvpCell.KeyInputTypeLabel.gameObject.SetActive(false);
+ kvpCell.KeyLabel.gameObject.SetActive(true);
+ kvpCell.KeyInspectButton.Button.gameObject.SetActive(InspectWanted);
+
+ kvpCell.KeyLabel.text = KeyLabelText;
+ }
+ }
+
+ public override void SetUserValue(object value)
+ {
+ throw new NotImplementedException("TODO");
+ }
+
+
+ protected override bool SetCellEvaluateState(CacheObjectCell cell)
+ {
+ // not needed
+ return false;
+ }
+ }
+}
diff --git a/src/UI/Inspectors/CacheObject/CacheListEntry.cs b/src/UI/Inspectors/CacheObject/CacheListEntry.cs
index 3467db9..cda99fc 100644
--- a/src/UI/Inspectors/CacheObject/CacheListEntry.cs
+++ b/src/UI/Inspectors/CacheObject/CacheListEntry.cs
@@ -9,16 +9,15 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
public class CacheListEntry : CacheObjectBase
{
- public InteractiveList CurrentList { get; set; }
-
public int ListIndex;
public override bool ShouldAutoEvaluate => true;
public override bool HasArguments => false;
+ public override bool CanWrite => Owner.CanWrite;
- public void SetListOwner(InteractiveList iList, int listIndex)
+ public void SetListOwner(InteractiveList list, int listIndex)
{
- this.CurrentList = iList;
+ this.Owner = list;
this.ListIndex = listIndex;
}
@@ -29,6 +28,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
var listCell = cell as CacheListEntryCell;
listCell.NameLabel.text = $"{ListIndex}:";
+ listCell.Image.color = ListIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor;
}
public override void SetUserValue(object value)
diff --git a/src/UI/Inspectors/CacheObject/CacheMember.cs b/src/UI/Inspectors/CacheObject/CacheMember.cs
index 83220f6..b5a83a8 100644
--- a/src/UI/Inspectors/CacheObject/CacheMember.cs
+++ b/src/UI/Inspectors/CacheObject/CacheMember.cs
@@ -11,7 +11,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
public abstract class CacheMember : CacheObjectBase
{
- public ReflectionInspector ParentInspector { get; internal set; }
+ //public ReflectionInspector ParentInspector { get; internal set; }
//public bool AutoUpdateWanted { get; internal set; }
public abstract Type DeclaringType { get; }
@@ -23,7 +23,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
public virtual void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member)
{
- this.ParentInspector = inspector;
+ this.Owner = inspector;
this.NameLabelText = SignatureHighlighter.ParseFullSyntax(member.DeclaringType, false, member);
this.NameForFiltering = $"{member.DeclaringType.Name}.{member.Name}";
}
@@ -82,6 +82,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
// todo evaluate buttons etc
SetValueState(cell, ValueStateArgs.Default);
+ cell.RefreshSubcontentButton();
return true;
}
@@ -235,7 +236,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
cachedSigs.Add(sig);
//cached.Initialize(_inspector, declaringType, member, returnType);
- cached.Initialize(returnType);
+ cached.SetFallbackType(returnType);
cached.SetInspectorOwner(_inspector, member);
list.Add(cached);
diff --git a/src/UI/Inspectors/CacheObject/CacheMethod.cs b/src/UI/Inspectors/CacheObject/CacheMethod.cs
index c5f204c..3985466 100644
--- a/src/UI/Inspectors/CacheObject/CacheMethod.cs
+++ b/src/UI/Inspectors/CacheObject/CacheMethod.cs
@@ -10,6 +10,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
public MethodInfo MethodInfo { get; internal set; }
public override Type DeclaringType => MethodInfo.DeclaringType;
+ public override bool CanWrite => false;
public override bool ShouldAutoEvaluate => false;
diff --git a/src/UI/Inspectors/CacheObject/CacheObjectBase.cs b/src/UI/Inspectors/CacheObject/CacheObjectBase.cs
index dd9ca95..1e979ed 100644
--- a/src/UI/Inspectors/CacheObject/CacheObjectBase.cs
+++ b/src/UI/Inspectors/CacheObject/CacheObjectBase.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
+using UnityEngine.UI;
using UnityExplorer.UI.Inspectors.CacheObject.Views;
using UnityExplorer.UI.Inspectors.IValues;
using UnityExplorer.UI.ObjectPool;
@@ -29,30 +30,30 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
public abstract class CacheObjectBase
{
- public CacheObjectCell CellView { get; internal set; }
+ public ICacheObjectController Owner { get; set; }
- public InteractiveValue IValue { get; private set; }
- public Type CurrentIValueType { get; private set; }
- public bool SubContentState { get; private set; }
+ public CacheObjectCell CellView { get; internal set; }
public object Value { get; protected set; }
public Type FallbackType { get; protected set; }
+ public InteractiveValue IValue { get; private set; }
+ public Type CurrentIValueType { get; private set; }
+ public bool SubContentShowWanted { get; private set; }
+
public string NameLabelText { get; protected set; }
- //public string TypeLabelText { get; set; }
public string ValueLabelText { get; protected set; }
public abstract bool ShouldAutoEvaluate { get; }
public abstract bool HasArguments { get; }
- public bool CanWrite { get; protected set; }
+ public abstract bool CanWrite { get; }
public bool HadException { get; protected set; }
public Exception LastException { get; protected set; }
- public virtual void Initialize(Type fallbackType)
+ public virtual void SetFallbackType(Type fallbackType)
{
this.FallbackType = fallbackType;
- //this.TypeLabelText = SignatureHighlighter.ParseFullType(FallbackType, false);
- this.ValueLabelText = GetValueLabel();
+ GetValueLabel();
}
// internals
@@ -144,44 +145,50 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
State = ValueState.String;
else if (type.IsEnum)
State = ValueState.Enum;
- else if (type.IsEnumerable())
- State = ValueState.Collection;
+
+ // todo Color and ValueStruct
+
else if (type.IsDictionary())
State = ValueState.Dictionary;
- // todo Color and ValueStruct
+ else if (type.IsEnumerable())
+ State = ValueState.Collection;
else
State = ValueState.Unsupported;
}
// Set label text
- ValueLabelText = GetValueLabel();
+ GetValueLabel();
}
- protected string GetValueLabel()
+ protected void GetValueLabel()
{
+ string label;
switch (State)
{
case ValueState.NotEvaluated:
- return $"{NOT_YET_EVAL} ({SignatureHighlighter.ParseFullType(FallbackType, true)})";
+ label = $"{NOT_YET_EVAL} ({SignatureHighlighter.ParseFullType(FallbackType, true)})"; break;
case ValueState.Exception:
- return $"{ReflectionUtility.ReflectionExToString(LastException)}";
+ label = $"{ReflectionUtility.ReflectionExToString(LastException)}"; break;
case ValueState.Boolean:
case ValueState.Number:
- return null;
+ label = null; break;
case ValueState.String:
string s = Value as string;
if (s.Length > 200)
s = $"{s.Substring(0, 200)}...";
- return $"\"{s}\"";
+ label = $"\"{s}\""; break;
case ValueState.NullValue:
- return $"{ToStringUtility.ToStringWithType(Value, FallbackType, true)}";
+ label = $"{ToStringUtility.ToStringWithType(Value, FallbackType, true)}"; break;
case ValueState.Enum:
case ValueState.Collection:
+ case ValueState.Dictionary:
case ValueState.ValueStruct:
+ case ValueState.Color:
case ValueState.Unsupported:
default:
- return ToStringUtility.ToStringWithType(Value, FallbackType, true);
+ label = ToStringUtility.ToStringWithType(Value, FallbackType, true); break;
}
+ this.ValueLabelText = label;
}
/// Return true if SetCell should abort, false if it should continue.
@@ -192,9 +199,12 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
cell.NameLabel.text = NameLabelText;
cell.ValueLabel.gameObject.SetActive(true);
- cell.SubContentHolder.gameObject.SetActive(SubContentState);
+ cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted);
if (IValue != null)
+ {
IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false);
+ IValue.SetLayout();
+ }
if (SetCellEvaluateState(cell))
return;
@@ -221,7 +231,9 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: true));
break;
case ValueState.Collection:
+ case ValueState.Dictionary:
case ValueState.ValueStruct:
+ case ValueState.Color:
SetIValueState();
SetValueState(cell, new ValueStateArgs(true, inspectActive: true, subContentButtonActive: true));
break;
@@ -229,6 +241,8 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
SetValueState(cell, new ValueStateArgs(true, inspectActive: true));
break;
}
+
+ cell.RefreshSubcontentButton();
}
protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
@@ -285,11 +299,11 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
IValue = (InteractiveValue)Pool.Borrow(ivalueType);
CurrentIValueType = ivalueType;
- IValue.SetOwner(this);
+ IValue.OnBorrowed(this);
IValue.SetValue(this.Value);
IValue.UIRoot.transform.SetParent(CellView.SubContentHolder.transform, false);
CellView.SubContentHolder.SetActive(true);
- SubContentState = true;
+ SubContentShowWanted = true;
// update our cell after creating the ivalue (the value may have updated, make sure its consistent)
this.ProcessOnEvaluate();
@@ -297,9 +311,11 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
}
else
{
- SubContentState = !SubContentState;
- CellView.SubContentHolder.SetActive(SubContentState);
+ SubContentShowWanted = !SubContentShowWanted;
+ CellView.SubContentHolder.SetActive(SubContentShowWanted);
}
+
+ CellView.RefreshSubcontentButton();
}
public virtual void ReleaseIValue()
@@ -335,13 +351,14 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
SetUserValue(this.CellView.Toggle.isOn);
else
{
- if (!numberParseMethods.ContainsKey(FallbackType.AssemblyQualifiedName))
+ var type = Value.GetActualType();
+ if (!numberParseMethods.ContainsKey(type.AssemblyQualifiedName))
{
- var method = FallbackType.GetMethod("Parse", new Type[] { typeof(string) });
- numberParseMethods.Add(FallbackType.AssemblyQualifiedName, method);
+ var method = type.GetMethod("Parse", new Type[] { typeof(string) });
+ numberParseMethods.Add(type.AssemblyQualifiedName, method);
}
- var val = numberParseMethods[FallbackType.AssemblyQualifiedName]
+ var val = numberParseMethods[type.AssemblyQualifiedName]
.Invoke(null, new object[] { CellView.InputField.text });
SetUserValue(val);
}
diff --git a/src/UI/Inspectors/CacheObject/CacheProperty.cs b/src/UI/Inspectors/CacheObject/CacheProperty.cs
index 679b02c..1981a09 100644
--- a/src/UI/Inspectors/CacheObject/CacheProperty.cs
+++ b/src/UI/Inspectors/CacheObject/CacheProperty.cs
@@ -10,6 +10,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
public PropertyInfo PropertyInfo { get; internal set; }
public override Type DeclaringType => PropertyInfo.DeclaringType;
+ public override bool CanWrite => PropertyInfo.CanWrite;
public override bool ShouldAutoEvaluate => !HasArguments;
@@ -17,7 +18,6 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
base.SetInspectorOwner(inspector, member);
- this.CanWrite = PropertyInfo.CanWrite;
Arguments = PropertyInfo.GetIndexParameters();
}
@@ -25,7 +25,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
try
{
- Value = PropertyInfo.GetValue(ParentInspector.Target.TryCast(DeclaringType), null);
+ Value = PropertyInfo.GetValue(Owner.Target.TryCast(DeclaringType), null);
}
catch (Exception ex)
{
@@ -43,7 +43,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
{
// TODO property indexers
- PropertyInfo.SetValue(PropertyInfo.GetSetMethod().IsStatic ? null : ParentInspector.Target, value, null);
+ PropertyInfo.SetValue(PropertyInfo.GetSetMethod().IsStatic ? null : Owner.Target, value, null);
}
catch (Exception ex)
{
diff --git a/src/UI/Inspectors/CacheObject/Views/CacheKeyValuePairCell.cs b/src/UI/Inspectors/CacheObject/Views/CacheKeyValuePairCell.cs
new file mode 100644
index 0000000..72e728c
--- /dev/null
+++ b/src/UI/Inspectors/CacheObject/Views/CacheKeyValuePairCell.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+using UnityEngine.UI;
+using UnityExplorer.UI.Inspectors.IValues;
+using UnityExplorer.UI.Widgets;
+
+namespace UnityExplorer.UI.Inspectors.CacheObject.Views
+{
+ public class CacheKeyValuePairCell : CacheObjectCell
+ {
+ public Image Image { get; private set; }
+ public InteractiveDictionary DictOwner => Occupant.Owner as InteractiveDictionary;
+
+ public LayoutElement KeyGroupLayout;
+ public Text KeyLabel;
+ public ButtonRef KeyInspectButton;
+ public InputField KeyInputField;
+ public Text KeyInputTypeLabel;
+
+ public static Color EvenColor = new Color(0.07f, 0.07f, 0.07f);
+ public static Color OddColor = new Color(0.063f, 0.063f, 0.063f);
+
+ public int HalfWidth => (int)(0.5f * Rect.rect.width);
+ public int AdjustedKeyWidth => HalfWidth - 50;
+
+ private void KeyInspectClicked()
+ {
+ InspectorManager.Inspect((Occupant as CacheKeyValuePair).DictKey, this.Occupant);
+ }
+
+ public override GameObject CreateContent(GameObject parent)
+ {
+ var root = base.CreateContent(parent);
+
+ Image = root.AddComponent();
+
+ this.NameLayout.minWidth = 40;
+ this.NameLayout.flexibleWidth = 50;
+ this.NameLayout.minHeight = 30;
+ this.NameLabel.alignment = TextAnchor.MiddleRight;
+
+ this.RightGroupLayout.minWidth = HalfWidth;
+
+ // Key area
+ var keyGroup = UIFactory.CreateUIObject("KeyHolder", root.transform.Find("HoriGroup").gameObject);
+ UIFactory.SetLayoutGroup(keyGroup, false, false, true, true, 2, 0, 0, 4, 4, childAlignment: TextAnchor.MiddleLeft);
+ UIFactory.SetLayoutElement(keyGroup, minHeight: 30, minWidth: AdjustedKeyWidth, flexibleWidth: 0);
+ KeyGroupLayout = keyGroup.GetComponent();
+
+ // set to be after the NameLabel (our index label), and before the main horizontal group.
+ keyGroup.transform.SetSiblingIndex(1);
+
+ // key Inspect
+
+ KeyInspectButton = UIFactory.CreateButton(keyGroup, "KeyInspectButton", "Inspect", new Color(0.15f, 0.15f, 0.15f));
+ UIFactory.SetLayoutElement(KeyInspectButton.Button.gameObject, minWidth: 60, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
+ InspectButton.OnClick += KeyInspectClicked;
+
+ // label
+
+ KeyLabel = UIFactory.CreateLabel(keyGroup, "KeyLabel", "not set (key)", TextAnchor.MiddleLeft);
+ UIFactory.SetLayoutElement(KeyLabel.gameObject, minWidth: 50, flexibleWidth: 999, minHeight: 30);
+
+ // Type label for input field
+
+ KeyInputTypeLabel = UIFactory.CreateLabel(keyGroup, "InputTypeLabel", "not set", TextAnchor.MiddleLeft);
+ UIFactory.SetLayoutElement(KeyInputTypeLabel.gameObject, minWidth: 55, flexibleWidth: 0, minHeight: 30);
+
+ // input field
+
+ var keyInputObj = UIFactory.CreateInputField(keyGroup, "KeyInput", "not set", out KeyInputField);
+ UIFactory.SetLayoutElement(keyInputObj, minHeight: 30, flexibleHeight: 0, flexibleWidth: 200);
+ //KeyInputField.lineType = InputField.LineType.MultiLineNewline;
+ KeyInputField.readOnly = true;
+
+ return root;
+ }
+
+ protected override void ConstructEvaluateHolder(GameObject parent)
+ {
+ // not used
+ }
+
+ //protected override void ConstructUpdateToggle(GameObject parent)
+ //{
+ // // not used
+ //}
+ }
+}
diff --git a/src/UI/Inspectors/CacheObject/Views/CacheListEntryCell.cs b/src/UI/Inspectors/CacheObject/Views/CacheListEntryCell.cs
index 422eab9..fd7e5b3 100644
--- a/src/UI/Inspectors/CacheObject/Views/CacheListEntryCell.cs
+++ b/src/UI/Inspectors/CacheObject/Views/CacheListEntryCell.cs
@@ -3,20 +3,29 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
+using UnityEngine.UI;
using UnityExplorer.UI.Inspectors.IValues;
namespace UnityExplorer.UI.Inspectors.CacheObject.Views
{
public class CacheListEntryCell : CacheObjectCell
{
- public InteractiveList ListOwner { get; set; }
+ public Image Image { get; private set; }
+ public InteractiveList ListOwner => Occupant.Owner as InteractiveList;
+
+ public static Color EvenColor = new Color(0.07f, 0.07f, 0.07f);
+ public static Color OddColor = new Color(0.063f, 0.063f, 0.063f);
public override GameObject CreateContent(GameObject parent)
{
var root = base.CreateContent(parent);
- this.NameLayout.minWidth = 50;
- this.NameLayout.flexibleWidth = 50f;
+ Image = root.AddComponent();
+
+ this.NameLayout.minWidth = 40;
+ this.NameLayout.flexibleWidth = 50;
+ this.NameLayout.minHeight = 30;
+ this.NameLabel.alignment = TextAnchor.MiddleRight;
return root;
}
diff --git a/src/UI/Inspectors/CacheObject/Views/CacheObjectCell.cs b/src/UI/Inspectors/CacheObject/Views/CacheObjectCell.cs
index d17ed3d..b6c6678 100644
--- a/src/UI/Inspectors/CacheObject/Views/CacheObjectCell.cs
+++ b/src/UI/Inspectors/CacheObject/Views/CacheObjectCell.cs
@@ -64,7 +64,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
protected virtual void InspectClicked()
{
- InspectorManager.Inspect(Occupant.Value);
+ InspectorManager.Inspect(Occupant.Value, this.Occupant);
}
protected virtual void ToggleClicked(bool value)
@@ -77,6 +77,23 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
this.Occupant.OnCellSubContentToggle();
}
+ private readonly Color subInactiveColor = new Color(0.23f, 0.23f, 0.23f);
+ private readonly Color subActiveColor = new Color(0.23f, 0.33f, 0.23f);
+
+ public void RefreshSubcontentButton()
+ {
+ if (!this.SubContentHolder.activeSelf)
+ {
+ this.SubContentButton.ButtonText.text = "▲";
+ RuntimeProvider.Instance.SetColorBlock(SubContentButton.Button, subInactiveColor, subInactiveColor * 1.3f);
+ }
+ else
+ {
+ this.SubContentButton.ButtonText.text = "▼";
+ RuntimeProvider.Instance.SetColorBlock(SubContentButton.Button, subActiveColor, subActiveColor * 1.3f);
+ }
+ }
+
protected abstract void ConstructEvaluateHolder(GameObject parent);
// protected abstract void ConstructUpdateToggle(GameObject parent);
@@ -89,16 +106,16 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
UIRoot = UIFactory.CreateUIObject(this.GetType().Name, parent, new Vector2(100, 30));
Rect = UIRoot.GetComponent();
- UIFactory.SetLayoutGroup(UIRoot, true, false, true, true, 0, 0);
+ UIFactory.SetLayoutGroup(UIRoot, false, false, true, true, 0, 0);
UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600);
UIRoot.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
- var content = UIFactory.CreateUIObject("Content", UIRoot);
- UIFactory.SetLayoutGroup(content, true, false, true, true, 2, 0);
- UIFactory.SetLayoutElement(content, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600);
- content.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
+ //var content = UIFactory.CreateUIObject("Content", UIRoot);
+ //UIFactory.SetLayoutGroup(content, true, false, true, true, 2, 0);
+ //UIFactory.SetLayoutElement(content, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600);
+ //content.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
- var horiRow = UIFactory.CreateUIObject("HoriGroup", content);
+ var horiRow = UIFactory.CreateUIObject("HoriGroup", UIRoot);
UIFactory.SetLayoutElement(horiRow, minHeight: 29, flexibleHeight: 150, flexibleWidth: 9999);
UIFactory.SetLayoutGroup(horiRow, false, false, true, true, 5, 2, childAlignment: TextAnchor.UpperLeft);
horiRow.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
@@ -125,7 +142,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
UIFactory.SetLayoutGroup(rightHoriGroup, false, false, true, true, 4, childAlignment: TextAnchor.UpperLeft);
UIFactory.SetLayoutElement(rightHoriGroup, minHeight: 25, minWidth: 200, flexibleWidth: 9999, flexibleHeight: 800);
- SubContentButton = UIFactory.CreateButton(rightHoriGroup, "SubContentButton", "▲");
+ SubContentButton = UIFactory.CreateButton(rightHoriGroup, "SubContentButton", "▲", subInactiveColor);
UIFactory.SetLayoutElement(SubContentButton.Button.gameObject, minWidth: 25, minHeight: 25, flexibleWidth: 0, flexibleHeight: 0);
SubContentButton.OnClick += SubContentClicked;
@@ -163,10 +180,10 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
// Subcontent
- SubContentHolder = UIFactory.CreateUIObject("SubContent", content);
- UIFactory.SetLayoutElement(SubContentHolder.gameObject, minHeight: 30, flexibleHeight: 500, minWidth: 100, flexibleWidth: 9999);
- UIFactory.SetLayoutGroup(SubContentHolder, true, false, true, true, 2, childAlignment: TextAnchor.UpperLeft);
-
+ SubContentHolder = UIFactory.CreateUIObject("SubContent", UIRoot);
+ UIFactory.SetLayoutElement(SubContentHolder.gameObject, minHeight: 30, flexibleHeight: 600, minWidth: 100, flexibleWidth: 9999);
+ UIFactory.SetLayoutGroup(SubContentHolder, true, true, true, true, 2, childAlignment: TextAnchor.UpperLeft);
+ //SubContentHolder.AddComponent().verticalFit = ContentSizeFitter.FitMode.MinSize;
SubContentHolder.SetActive(false);
// Bottom separator
diff --git a/src/UI/Inspectors/GameObjectInspector.cs b/src/UI/Inspectors/GameObjectInspector.cs
index 4cf2974..1883293 100644
--- a/src/UI/Inspectors/GameObjectInspector.cs
+++ b/src/UI/Inspectors/GameObjectInspector.cs
@@ -14,7 +14,8 @@ namespace UnityExplorer.UI.Inspectors
{
public class GameObjectInspector : InspectorBase
{
- public GameObject Target;
+ //public GameObject Target;
+ public GameObject GOTarget => Target as GameObject;
private Text NameText;
@@ -32,8 +33,8 @@ namespace UnityExplorer.UI.Inspectors
Target = target as GameObject;
- NameText.text = Target.name;
- Tab.TabText.text = $"[G] {Target.name}";
+ NameText.text = GOTarget.name;
+ Tab.TabText.text = $"[G] {GOTarget.name}";
RuntimeProvider.Instance.StartCoroutine(InitCoroutine());
}
@@ -84,15 +85,15 @@ namespace UnityExplorer.UI.Inspectors
UpdateComponents();
- Tab.TabText.text = $"[G] {Target.name}";
+ Tab.TabText.text = $"[G] {GOTarget.name}";
}
}
private IEnumerable GetTransformEntries()
{
_rootEntries.Clear();
- for (int i = 0; i < Target.transform.childCount; i++)
- _rootEntries.Add(Target.transform.GetChild(i).gameObject);
+ for (int i = 0; i < GOTarget.transform.childCount; i++)
+ _rootEntries.Add(GOTarget.transform.GetChild(i).gameObject);
return _rootEntries;
}
@@ -141,7 +142,7 @@ namespace UnityExplorer.UI.Inspectors
private void UpdateComponents()
{
_componentEntries.Clear();
- var comps = Target.GetComponents();
+ var comps = GOTarget.GetComponents();
foreach (var comp in comps)
_componentEntries.Add(comp);
diff --git a/src/UI/Inspectors/ICacheObjectController.cs b/src/UI/Inspectors/ICacheObjectController.cs
new file mode 100644
index 0000000..383e075
--- /dev/null
+++ b/src/UI/Inspectors/ICacheObjectController.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityExplorer.UI.Inspectors.CacheObject;
+
+namespace UnityExplorer.UI.Inspectors
+{
+ public interface ICacheObjectController
+ {
+ CacheObjectBase ParentCacheObject { get; } // TODO
+
+ object Target { get; }
+ Type TargetType { get; }
+
+ bool CanWrite { get; }
+ }
+}
diff --git a/src/UI/Inspectors/IValues/InteractiveDictionary.cs b/src/UI/Inspectors/IValues/InteractiveDictionary.cs
new file mode 100644
index 0000000..c18f025
--- /dev/null
+++ b/src/UI/Inspectors/IValues/InteractiveDictionary.cs
@@ -0,0 +1,250 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using UnityEngine.UI;
+using UnityExplorer.UI.Inspectors.CacheObject;
+using UnityExplorer.UI.Inspectors.CacheObject.Views;
+using UnityExplorer.UI.Utility;
+using UnityExplorer.UI.Widgets;
+
+namespace UnityExplorer.UI.Inspectors.IValues
+{
+ public class InteractiveDictionary : InteractiveValue, IPoolDataSource, ICacheObjectController
+ {
+ CacheObjectBase ICacheObjectController.ParentCacheObject => this.CurrentOwner;
+ object ICacheObjectController.Target => this.CurrentOwner.Value;
+ public Type TargetType { get; private set; }
+
+ public override bool CanWrite => false;// TODO RefIDictionary != null && !RefIDictionary.IsReadOnly;
+
+ public Type KeyType;
+ public Type ValueType;
+ public IDictionary RefIDictionary;
+
+ public int ItemCount => values.Count;
+ private readonly List