mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-14 07:37:06 +08:00
Fix casting for dictionary keys, only cast displayed key
And fix layout
This commit is contained in:
@ -14,6 +14,7 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
|
|
||||||
public int DictIndex;
|
public int DictIndex;
|
||||||
public object DictKey;
|
public object DictKey;
|
||||||
|
public object DisplayedKey;
|
||||||
|
|
||||||
public bool KeyInputWanted;
|
public bool KeyInputWanted;
|
||||||
public bool InspectWanted;
|
public bool InspectWanted;
|
||||||
@ -37,18 +38,20 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
public void SetKey(object key)
|
public void SetKey(object key)
|
||||||
{
|
{
|
||||||
this.DictKey = key;
|
this.DictKey = key;
|
||||||
var type = key.GetActualType();
|
this.DisplayedKey = key.TryCast();
|
||||||
if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))) || type == typeof(decimal))
|
|
||||||
|
var type = DisplayedKey.GetType();
|
||||||
|
if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))))
|
||||||
{
|
{
|
||||||
KeyInputWanted = true;
|
KeyInputWanted = true;
|
||||||
KeyInputText = key.ToString();
|
KeyInputText = DisplayedKey.ToString();
|
||||||
KeyInputTypeText = SignatureHighlighter.Parse(type, false);
|
KeyInputTypeText = SignatureHighlighter.Parse(type, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KeyInputWanted = false;
|
KeyInputWanted = false;
|
||||||
InspectWanted = type != typeof(bool) && !type.IsEnum;
|
InspectWanted = type != typeof(bool) && !type.IsEnum;
|
||||||
KeyLabelText = ToStringUtility.ToStringWithType(key, type, true);
|
KeyLabelText = ToStringUtility.ToStringWithType(DisplayedKey, type, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,11 @@ namespace UnityExplorer.UI.CacheObject.Views
|
|||||||
public static Color EvenColor = new Color(0.07f, 0.07f, 0.07f);
|
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 static Color OddColor = new Color(0.063f, 0.063f, 0.063f);
|
||||||
|
|
||||||
public int HalfWidth => (int)(0.5f * Rect.rect.width) + 50;
|
public int AdjustedWidth => (int)Rect.rect.width - 70;
|
||||||
public int AdjustedKeyWidth => HalfWidth - 100;
|
|
||||||
|
//public int HalfWidth => (int)(0.5f * Rect.rect.width) - 75;
|
||||||
|
//public int AdjustedKeyWidth => HalfWidth - 50;
|
||||||
|
//public int AdjustedRightWidth => HalfWidth;
|
||||||
|
|
||||||
private void KeyInspectClicked()
|
private void KeyInspectClicked()
|
||||||
{
|
{
|
||||||
@ -38,18 +41,18 @@ namespace UnityExplorer.UI.CacheObject.Views
|
|||||||
|
|
||||||
Image = root.AddComponent<Image>();
|
Image = root.AddComponent<Image>();
|
||||||
|
|
||||||
this.NameLayout.minWidth = 55;
|
this.NameLayout.minWidth = 70;
|
||||||
this.NameLayout.flexibleWidth = 50;
|
this.NameLayout.flexibleWidth = 0;
|
||||||
this.NameLayout.minHeight = 30;
|
this.NameLayout.minHeight = 30;
|
||||||
this.NameLayout.flexibleHeight = 0;
|
this.NameLayout.flexibleHeight = 0;
|
||||||
this.NameLabel.alignment = TextAnchor.MiddleRight;
|
this.NameLabel.alignment = TextAnchor.MiddleRight;
|
||||||
|
|
||||||
this.RightGroupLayout.minWidth = HalfWidth;
|
this.RightGroupLayout.minWidth = AdjustedWidth * 0.55f;
|
||||||
|
|
||||||
// Key area
|
// Key area
|
||||||
var keyGroup = UIFactory.CreateUIObject("KeyHolder", root.transform.Find("HoriGroup").gameObject);
|
var keyGroup = UIFactory.CreateUIObject("KeyHolder", root.transform.Find("HoriGroup").gameObject);
|
||||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(keyGroup, false, false, true, true, 2, 0, 0, 4, 4, childAlignment: TextAnchor.MiddleLeft);
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(keyGroup, false, false, true, true, 2, 0, 0, 4, 4, childAlignment: TextAnchor.MiddleLeft);
|
||||||
KeyGroupLayout = UIFactory.SetLayoutElement(keyGroup, minHeight: 30, minWidth: AdjustedKeyWidth, flexibleWidth: 0);
|
KeyGroupLayout = UIFactory.SetLayoutElement(keyGroup, minHeight: 30, minWidth: (int)(AdjustedWidth * 0.44f), flexibleWidth: 0);
|
||||||
|
|
||||||
// set to be after the NameLabel (our index label), and before the main horizontal group.
|
// set to be after the NameLabel (our index label), and before the main horizontal group.
|
||||||
keyGroup.transform.SetSiblingIndex(1);
|
keyGroup.transform.SetSiblingIndex(1);
|
||||||
@ -73,7 +76,7 @@ namespace UnityExplorer.UI.CacheObject.Views
|
|||||||
// input field
|
// input field
|
||||||
|
|
||||||
var keyInputObj = UIFactory.CreateInputField(keyGroup, "KeyInput", "empty", out KeyInputField);
|
var keyInputObj = UIFactory.CreateInputField(keyGroup, "KeyInput", "empty", out KeyInputField);
|
||||||
UIFactory.SetLayoutElement(keyInputObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 200);
|
UIFactory.SetLayoutElement(keyInputObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 0, preferredWidth: 200);
|
||||||
//KeyInputField.lineType = InputField.LineType.MultiLineNewline;
|
//KeyInputField.lineType = InputField.LineType.MultiLineNewline;
|
||||||
KeyInputField.readOnly = true;
|
KeyInputField.readOnly = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user