diff --git a/src/CachedObjects/Struct/CacheColor.cs b/src/CachedObjects/Struct/CacheColor.cs index 26b2d0f..b3ceee6 100644 --- a/src/CachedObjects/Struct/CacheColor.cs +++ b/src/CachedObjects/Struct/CacheColor.cs @@ -21,6 +21,8 @@ namespace Explorer { base.UpdateValue(); + if (Value == null) return; + var color = (Color)Value; r = color.r.ToString(); diff --git a/src/CachedObjects/Struct/CacheEnum.cs b/src/CachedObjects/Struct/CacheEnum.cs index f90d8f7..45933e7 100644 --- a/src/CachedObjects/Struct/CacheEnum.cs +++ b/src/CachedObjects/Struct/CacheEnum.cs @@ -11,23 +11,19 @@ namespace Explorer { public class CacheEnum : CacheObjectBase { - public Type EnumType; + // public Type EnumType; public string[] EnumNames; public override void Init() { - try + if (ValueType == null && Value != null) { - EnumType = Value.GetType(); - } - catch - { - EnumType = (MemInfo as FieldInfo)?.FieldType ?? (MemInfo as PropertyInfo).PropertyType; + ValueType = Value.GetType(); } - if (EnumType != null) + if (ValueType != null) { - EnumNames = Enum.GetNames(EnumType); + EnumNames = Enum.GetNames(ValueType); } else { @@ -62,7 +58,7 @@ namespace Explorer if ((change < 0 && newindex >= 0) || (change > 0 && newindex < names.Count)) { - value = Enum.Parse(EnumType, names[newindex]); + value = Enum.Parse(ValueType, names[newindex]); } } } diff --git a/src/CachedObjects/Struct/CacheQuaternion.cs b/src/CachedObjects/Struct/CacheQuaternion.cs index 373d56b..5905787 100644 --- a/src/CachedObjects/Struct/CacheQuaternion.cs +++ b/src/CachedObjects/Struct/CacheQuaternion.cs @@ -20,6 +20,8 @@ namespace Explorer { base.UpdateValue(); + if (Value == null) return; + var euler = ((Quaternion)Value).eulerAngles; x = euler.x.ToString(); diff --git a/src/CachedObjects/Struct/CacheRect.cs b/src/CachedObjects/Struct/CacheRect.cs index 5d3ed22..857ffef 100644 --- a/src/CachedObjects/Struct/CacheRect.cs +++ b/src/CachedObjects/Struct/CacheRect.cs @@ -21,6 +21,8 @@ namespace Explorer { base.UpdateValue(); + if (Value == null) return; + var rect = (Rect)Value; x = rect.x.ToString(); diff --git a/src/CachedObjects/Struct/CacheVector.cs b/src/CachedObjects/Struct/CacheVector.cs index 8b0087a..6bf01a6 100644 --- a/src/CachedObjects/Struct/CacheVector.cs +++ b/src/CachedObjects/Struct/CacheVector.cs @@ -24,20 +24,26 @@ namespace Explorer public override void Init() { - if (Value is Vector2) + if (ValueType == null && Value != null) + { + ValueType = Value.GetType(); + } + + if (ValueType == typeof(Vector2)) { VectorSize = 2; + m_toStringMethod = typeof(Vector2).GetMethod("ToString", new Type[0]); } - else if (Value is Vector3) + else if (ValueType == typeof(Vector3)) { VectorSize = 3; + m_toStringMethod = typeof(Vector3).GetMethod("ToString", new Type[0]); } else { VectorSize = 4; + m_toStringMethod = typeof(Vector4).GetMethod("ToString", new Type[0]); } - - m_toStringMethod = Value.GetType().GetMethod("ToString", new Type[0]); } public override void UpdateValue()