Fix casting for dictionary keys, only cast displayed key

And fix layout
This commit is contained in:
Sinai
2021-05-07 06:27:23 +10:00
parent 00c28f781a
commit 1f996f52fe
2 changed files with 17 additions and 11 deletions

View File

@ -14,6 +14,7 @@ namespace UnityExplorer.UI.CacheObject
public int DictIndex;
public object DictKey;
public object DisplayedKey;
public bool KeyInputWanted;
public bool InspectWanted;
@ -37,18 +38,20 @@ namespace UnityExplorer.UI.CacheObject
public void SetKey(object key)
{
this.DictKey = key;
var type = key.GetActualType();
if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))) || type == typeof(decimal))
this.DisplayedKey = key.TryCast();
var type = DisplayedKey.GetType();
if (type == typeof(string) || (type.IsPrimitive && !(type == typeof(bool))))
{
KeyInputWanted = true;
KeyInputText = key.ToString();
KeyInputText = DisplayedKey.ToString();
KeyInputTypeText = SignatureHighlighter.Parse(type, false);
}
else
{
KeyInputWanted = false;
InspectWanted = type != typeof(bool) && !type.IsEnum;
KeyLabelText = ToStringUtility.ToStringWithType(key, type, true);
KeyLabelText = ToStringUtility.ToStringWithType(DisplayedKey, type, true);
}
}