mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
@ -93,13 +93,9 @@ namespace Explorer
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_objectType = type;
|
||||
GetFields(m_object);
|
||||
GetProperties(m_object);
|
||||
}
|
||||
catch { }
|
||||
m_objectType = type;
|
||||
GetFields(m_object);
|
||||
GetProperties(m_object);
|
||||
|
||||
UpdateValues();
|
||||
}
|
||||
@ -280,7 +276,7 @@ namespace Explorer
|
||||
|
||||
public static bool IsList(Type t)
|
||||
{
|
||||
return t.IsGenericType
|
||||
return t.IsGenericType
|
||||
&& t.GetGenericTypeDefinition() is Type typeDef
|
||||
&& (typeDef.IsAssignableFrom(typeof(List<>)) || typeDef.IsAssignableFrom(typeof(Il2CppSystem.Collections.Generic.List<>)));
|
||||
}
|
||||
@ -296,20 +292,8 @@ namespace Explorer
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
PropertyInfo[] propInfos = new PropertyInfo[0];
|
||||
|
||||
try
|
||||
foreach (var pi in type.GetProperties(At.flags))
|
||||
{
|
||||
propInfos = type.GetProperties(At.flags);
|
||||
}
|
||||
catch (TypeLoadException)
|
||||
{
|
||||
MelonLogger.Log($"Couldn't get Properties for Type '{type.Name}', it may not support Il2Cpp Reflection at the moment.");
|
||||
}
|
||||
|
||||
foreach (var pi in propInfos)
|
||||
{
|
||||
// this member causes a crash when inspected, so just skipping it for now.
|
||||
if (pi.Name == "Il2CppType")
|
||||
{
|
||||
continue;
|
||||
@ -351,7 +335,7 @@ namespace Explorer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *********************
|
||||
* PROPERTYINFO HOLDER
|
||||
@ -362,7 +346,6 @@ namespace Explorer
|
||||
public Type classType;
|
||||
public PropertyInfo propInfo;
|
||||
public object m_value;
|
||||
public bool IsExpanded;
|
||||
|
||||
public PropertyInfoHolder(Type _type, PropertyInfo _propInfo)
|
||||
{
|
||||
@ -372,7 +355,14 @@ namespace Explorer
|
||||
|
||||
public void Draw(ReflectionWindow window)
|
||||
{
|
||||
UIStyles.DrawMember(ref m_value, ref this.IsExpanded, this.propInfo, window.m_rect, window.m_object, SetValue);
|
||||
if (propInfo.CanWrite)
|
||||
{
|
||||
UIStyles.DrawMember(ref m_value, propInfo.PropertyType.Name, propInfo.Name, window.m_rect, window.m_object, SetValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIStyles.DrawMember(ref m_value, propInfo.PropertyType.Name, propInfo.Name, window.m_rect, window.m_object);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateValue(object obj)
|
||||
@ -399,15 +389,15 @@ namespace Explorer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MelonLogger.Log("Exception on PropertyInfoHolder.UpdateValue, Name: " + this.propInfo.Name);
|
||||
MelonLogger.Log(e.GetType() + ", " + e.Message);
|
||||
//MelonLogger.Log("Exception on PropertyInfoHolder.UpdateValue, Name: " + this.propInfo.Name);
|
||||
//MelonLogger.Log(e.GetType() + ", " + e.Message);
|
||||
|
||||
var inner = e.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
MelonLogger.Log("inner: " + inner.GetType() + ", " + inner.Message);
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
//var inner = e.InnerException;
|
||||
//while (inner != null)
|
||||
//{
|
||||
// MelonLogger.Log("inner: " + inner.GetType() + ", " + inner.Message);
|
||||
// inner = inner.InnerException;
|
||||
//}
|
||||
|
||||
m_value = null;
|
||||
}
|
||||
@ -483,7 +473,6 @@ namespace Explorer
|
||||
public Type classType;
|
||||
public FieldInfo fieldInfo;
|
||||
public object m_value;
|
||||
public bool IsExpanded;
|
||||
|
||||
public FieldInfoHolder(Type _type, FieldInfo _fieldInfo)
|
||||
{
|
||||
@ -498,7 +487,16 @@ namespace Explorer
|
||||
|
||||
public void Draw(ReflectionWindow window)
|
||||
{
|
||||
UIStyles.DrawMember(ref m_value, ref this.IsExpanded, this.fieldInfo, window.m_rect, window.m_object, SetValue);
|
||||
bool canSet = !(fieldInfo.IsLiteral && !fieldInfo.IsInitOnly);
|
||||
|
||||
if (canSet)
|
||||
{
|
||||
UIStyles.DrawMember(ref m_value, fieldInfo.FieldType.Name, fieldInfo.Name, window.m_rect, window.m_object, SetValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIStyles.DrawMember(ref m_value, fieldInfo.FieldType.Name, fieldInfo.Name, window.m_rect, window.m_object);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetValue(object obj)
|
||||
|
Reference in New Issue
Block a user