mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-03 16:13:25 +08:00
Fix for cases when structs return null (due to null declaring instance)
This commit is contained in:
parent
3639824df3
commit
04248a89ce
@ -21,6 +21,8 @@ namespace Explorer
|
||||
{
|
||||
base.UpdateValue();
|
||||
|
||||
if (Value == null) return;
|
||||
|
||||
var color = (Color)Value;
|
||||
|
||||
r = color.r.ToString();
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ namespace Explorer
|
||||
{
|
||||
base.UpdateValue();
|
||||
|
||||
if (Value == null) return;
|
||||
|
||||
var euler = ((Quaternion)Value).eulerAngles;
|
||||
|
||||
x = euler.x.ToString();
|
||||
|
@ -21,6 +21,8 @@ namespace Explorer
|
||||
{
|
||||
base.UpdateValue();
|
||||
|
||||
if (Value == null) return;
|
||||
|
||||
var rect = (Rect)Value;
|
||||
|
||||
x = rect.x.ToString();
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user