From 20298aa47b1bf1acafc4fe656bd02833e12f0004 Mon Sep 17 00:00:00 2001
From: Sinai <49360850+sinai-dev@users.noreply.github.com>
Date: Mon, 23 Aug 2021 18:35:08 +1000
Subject: [PATCH] Make Type and Member names selectable / copy+paste-able
---
src/CacheObject/CacheConfigEntry.cs | 4 ++--
src/CacheObject/CacheKeyValuePair.cs | 1 +
src/CacheObject/CacheListEntry.cs | 1 +
src/CacheObject/CacheMember.cs | 1 +
src/CacheObject/CacheObjectBase.cs | 3 +++
src/CacheObject/Views/CacheObjectCell.cs | 16 +++++++++++++--
src/Inspectors/ReflectionInspector.cs | 25 ++++++++++++++++++++++--
7 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/src/CacheObject/CacheConfigEntry.cs b/src/CacheObject/CacheConfigEntry.cs
index b03f0fc..ffce9ae 100644
--- a/src/CacheObject/CacheConfigEntry.cs
+++ b/src/CacheObject/CacheConfigEntry.cs
@@ -12,11 +12,11 @@ namespace UnityExplorer.CacheObject
public CacheConfigEntry(IConfigElement configElement)
{
this.RefConfigElement = configElement;
+ this.FallbackType = configElement.ElementType;
this.NameLabelText = $"{configElement.Name}" +
$"\r\n{configElement.Description}";
-
- this.FallbackType = configElement.ElementType;
+ this.NameLabelTextRaw = string.Empty;
configElement.OnValueChangedNotify += UpdateValueFromSource;
}
diff --git a/src/CacheObject/CacheKeyValuePair.cs b/src/CacheObject/CacheKeyValuePair.cs
index 54e8ba7..3665c58 100644
--- a/src/CacheObject/CacheKeyValuePair.cs
+++ b/src/CacheObject/CacheKeyValuePair.cs
@@ -61,6 +61,7 @@ namespace UnityExplorer.CacheObject
var kvpCell = cell as CacheKeyValuePairCell;
kvpCell.NameLabel.text = $"{DictIndex}:";
+ kvpCell.HiddenNameLabel.Text = "";
kvpCell.Image.color = DictIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor;
if (KeyInputWanted)
diff --git a/src/CacheObject/CacheListEntry.cs b/src/CacheObject/CacheListEntry.cs
index fe2481c..01e68b1 100644
--- a/src/CacheObject/CacheListEntry.cs
+++ b/src/CacheObject/CacheListEntry.cs
@@ -28,6 +28,7 @@ namespace UnityExplorer.CacheObject
var listCell = cell as CacheListEntryCell;
listCell.NameLabel.text = $"{ListIndex}:";
+ listCell.HiddenNameLabel.Text = "";
listCell.Image.color = ListIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor;
}
diff --git a/src/CacheObject/CacheMember.cs b/src/CacheObject/CacheMember.cs
index 2650c54..791d9d7 100644
--- a/src/CacheObject/CacheMember.cs
+++ b/src/CacheObject/CacheMember.cs
@@ -34,6 +34,7 @@ namespace UnityExplorer.CacheObject
this.Owner = inspector;
this.NameLabelText = SignatureHighlighter.Parse(member.DeclaringType, false, member);
this.NameForFiltering = $"{member.DeclaringType.Name}.{member.Name}";
+ this.NameLabelTextRaw = NameForFiltering;
}
public override void ReleasePooledObjects()
diff --git a/src/CacheObject/CacheObjectBase.cs b/src/CacheObject/CacheObjectBase.cs
index 2491094..8caa1e3 100644
--- a/src/CacheObject/CacheObjectBase.cs
+++ b/src/CacheObject/CacheObjectBase.cs
@@ -47,6 +47,7 @@ namespace UnityExplorer.CacheObject
public bool SubContentShowWanted { get; private set; }
public string NameLabelText { get; protected set; }
+ public string NameLabelTextRaw { get; protected set; }
public string ValueLabelText { get; protected set; }
public abstract bool ShouldAutoEvaluate { get; }
@@ -260,6 +261,8 @@ namespace UnityExplorer.CacheObject
public virtual void SetDataToCell(CacheObjectCell cell)
{
cell.NameLabel.text = NameLabelText;
+ if (cell.HiddenNameLabel != null)
+ cell.HiddenNameLabel.Text = NameLabelTextRaw;
cell.ValueLabel.gameObject.SetActive(true);
cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted);
diff --git a/src/CacheObject/Views/CacheObjectCell.cs b/src/CacheObject/Views/CacheObjectCell.cs
index 147b2b1..6021b21 100644
--- a/src/CacheObject/Views/CacheObjectCell.cs
+++ b/src/CacheObject/Views/CacheObjectCell.cs
@@ -45,6 +45,7 @@ namespace UnityExplorer.CacheObject.Views
public LayoutElement RightGroupLayout;
public Text NameLabel;
+ public InputFieldRef HiddenNameLabel;
public Text TypeLabel;
public Text ValueLabel;
public Toggle Toggle;
@@ -116,8 +117,19 @@ namespace UnityExplorer.CacheObject.Views
NameLabel = UIFactory.CreateLabel(horiRow, "NameLabel", "", TextAnchor.MiddleLeft);
NameLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
- UIFactory.SetLayoutElement(NameLabel.gameObject, minHeight: 25, minWidth: 20, flexibleHeight: 300, flexibleWidth: 0);
- NameLayout = NameLabel.GetComponent();
+ NameLayout = UIFactory.SetLayoutElement(NameLabel.gameObject, minHeight: 25, minWidth: 20, flexibleHeight: 300, flexibleWidth: 0);
+ UIFactory.SetLayoutGroup(NameLabel.gameObject, true, true, true, true);
+
+ HiddenNameLabel = UIFactory.CreateInputField(NameLabel.gameObject, "HiddenNameLabel", "");
+ var hiddenRect = HiddenNameLabel.Component.GetComponent();
+ hiddenRect.anchorMin = Vector2.zero;
+ hiddenRect.anchorMax = Vector2.one;
+ HiddenNameLabel.Component.readOnly = true;
+ HiddenNameLabel.Component.lineType = UnityEngine.UI.InputField.LineType.MultiLineNewline;
+ HiddenNameLabel.Component.textComponent.horizontalOverflow = HorizontalWrapMode.Wrap;
+ HiddenNameLabel.Component.gameObject.GetComponent().color = Color.clear;
+ HiddenNameLabel.Component.textComponent.color = Color.clear;
+ UIFactory.SetLayoutElement(HiddenNameLabel.Component.gameObject, minHeight: 25, minWidth: 20, flexibleHeight: 300, flexibleWidth: 0);
// Right vertical group
diff --git a/src/Inspectors/ReflectionInspector.cs b/src/Inspectors/ReflectionInspector.cs
index 829122d..9eac3f2 100644
--- a/src/Inspectors/ReflectionInspector.cs
+++ b/src/Inspectors/ReflectionInspector.cs
@@ -47,6 +47,7 @@ namespace UnityExplorer.Inspectors
public ScrollPool MemberScrollPool { get; private set; }
+ public InputFieldRef HiddenNameText;
public Text NameText;
public Text AssemblyText;
private Toggle autoUpdateToggle;
@@ -125,6 +126,7 @@ namespace UnityExplorer.Inspectors
currentBaseTabText = $"{prefix} {SignatureHighlighter.Parse(TargetType, false)}";
Tab.TabText.text = currentBaseTabText;
NameText.text = SignatureHighlighter.Parse(TargetType, true);
+ HiddenNameText.Text = TargetType.FullName;
string asmText;
if (TargetType.Assembly is AssemblyBuilder || string.IsNullOrEmpty(TargetType.Assembly.Location))
@@ -332,8 +334,27 @@ namespace UnityExplorer.Inspectors
// Class name, assembly
- NameText = UIFactory.CreateLabel(UIRoot, "Title", "not set", TextAnchor.MiddleLeft, fontSize: 17);
- UIFactory.SetLayoutElement(NameText.gameObject, minHeight: 25, flexibleHeight: 0);
+ var titleHolder = UIFactory.CreateUIObject("TitleHolder", UIRoot);
+ UIFactory.SetLayoutElement(titleHolder, minHeight: 35, flexibleHeight: 0, flexibleWidth: 9999);
+
+ NameText = UIFactory.CreateLabel(titleHolder, "VisibleTitle", "NotSet", TextAnchor.MiddleLeft);
+ var namerect = NameText.GetComponent();
+ namerect.anchorMin = new Vector2(0, 0);
+ namerect.anchorMax = new Vector2(1, 1);
+ NameText.fontSize = 17;
+ UIFactory.SetLayoutElement(NameText.gameObject, minHeight: 35, flexibleHeight: 0, minWidth: 300, flexibleWidth: 9999);
+
+ HiddenNameText = UIFactory.CreateInputField(titleHolder, "Title", "not set");
+ var hiddenrect = HiddenNameText.Component.gameObject.GetComponent();
+ hiddenrect.anchorMin = new Vector2(0, 0);
+ hiddenrect.anchorMax = new Vector2(1, 1);
+ HiddenNameText.Component.readOnly = true;
+ HiddenNameText.Component.lineType = InputField.LineType.MultiLineNewline;
+ HiddenNameText.Component.gameObject.GetComponent().color = Color.clear;
+ HiddenNameText.Component.textComponent.horizontalOverflow = HorizontalWrapMode.Wrap;
+ HiddenNameText.Component.textComponent.fontSize = 17;
+ HiddenNameText.Component.textComponent.color = Color.clear;
+ UIFactory.SetLayoutElement(HiddenNameText.Component.gameObject, minHeight: 35, flexibleHeight: 0, flexibleWidth: 9999);
AssemblyText = UIFactory.CreateLabel(UIRoot, "AssemblyLabel", "not set", TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(AssemblyText.gameObject, minHeight: 25, flexibleWidth: 9999);