From 939861b5f03e91263bb28d98e5d6d498e35f1db1 Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Sat, 19 Sep 2020 01:44:38 +1000 Subject: [PATCH] Cleanup --- src/CachedObjects/CacheObjectBase.cs | 8 ++++---- src/CachedObjects/Other/CacheMethod.cs | 3 +-- src/CachedObjects/Other/CacheOther.cs | 18 ++++++------------ 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs index 6c14faf..f083b64 100644 --- a/src/CachedObjects/CacheObjectBase.cs +++ b/src/CachedObjects/CacheObjectBase.cs @@ -10,7 +10,6 @@ namespace Explorer public abstract class CacheObjectBase { public object Value; - public string ValueTypeName; public Type ValueType; public MemberInfo MemInfo { get; set; } @@ -175,7 +174,6 @@ namespace Explorer holder.Value = obj; holder.ValueType = valueType; - holder.ValueTypeName = valueType.FullName; if (memberInfo != null) { @@ -517,17 +515,19 @@ namespace Explorer GUIUnstrip.Space(labelWidth); } + string typeName = $"{ValueType.FullName}"; + if (!string.IsNullOrEmpty(ReflectionException)) { GUILayout.Label("Reflection failed! (" + ReflectionException + ")", null); } else if ((HasParameters || this is CacheMethod) && !m_evaluated) { - GUILayout.Label($"Not yet evaluated ({ValueTypeName})", null); + GUILayout.Label($"Not yet evaluated ({typeName})", null); } else if (Value == null && !(this is CacheMethod)) { - GUILayout.Label("null (" + ValueTypeName + ")", null); + GUILayout.Label($"null ({typeName})", null); } else { diff --git a/src/CachedObjects/Other/CacheMethod.cs b/src/CachedObjects/Other/CacheMethod.cs index d25b9aa..ae6fb62 100644 --- a/src/CachedObjects/Other/CacheMethod.cs +++ b/src/CachedObjects/Other/CacheMethod.cs @@ -29,7 +29,6 @@ namespace Explorer GenericArgInput = new string[GenericArgs.Length]; ValueType = mi.ReturnType; - ValueTypeName = ValueType.FullName; } public override void UpdateValue() @@ -121,7 +120,7 @@ namespace Explorer public override void DrawValue(Rect window, float width) { - string typeLabel = $"{ValueTypeName}"; + string typeLabel = $"{ValueType.FullName}"; if (m_evaluated) { diff --git a/src/CachedObjects/Other/CacheOther.cs b/src/CachedObjects/Other/CacheOther.cs index 983aa76..7916aa4 100644 --- a/src/CachedObjects/Other/CacheOther.cs +++ b/src/CachedObjects/Other/CacheOther.cs @@ -56,27 +56,21 @@ namespace Explorer ? UIStyles.Syntax.Class_Static : UIStyles.Syntax.Class_Instance; + string typeLabel = $"{ValueType.FullName}"; + if (Value is UnityEngine.Object) { - int typeStart = label.LastIndexOf("("); // get where the '(Type)' starts - var newLabel = label.Substring(0, typeStart + 1); // get just the name and first '(' - newLabel += $""; // add color tag - newLabel += label.Substring(typeStart + 1); // add the TypeName back in - newLabel = newLabel.Substring(0, newLabel.Length - 1); // remove the ending ')' - newLabel += ")"; // close color tag and put the ')' back. - label = newLabel; + label = label.Replace($"({ValueType.FullName})", $"({typeLabel})"); } else { - string classLabel = $"{ValueTypeName}"; - - if (!label.Contains(ValueTypeName)) + if (!label.Contains(ValueType.FullName)) { - label += $" ({classLabel})"; + label += $" ({typeLabel})"; } else { - label = label.Replace(ValueTypeName, $"{ValueTypeName}"); + label = label.Replace(ValueType.FullName, typeLabel); } }