private static void SetTypeMembertypeEntry(ExposedObjectDescriptor target) { int iMax = target.members.Length; target.memberTypes = new TypeClassification[iMax]; int i = iMax; while (--i > -1) { Type memberType = null; ICustomAttributeProvider member = target.members[i]; if (member is FieldInfo) { memberType = (member as FieldInfo).FieldType; } else if (member is PropertyInfo) { memberType = (member as PropertyInfo).PropertyType; } else { if (vBug.settings.general.debugMode) Debug.LogError("WTF? " + member.GetType().Name); target.memberTypes[i] = TypeClassification.unknown; continue; } GetObjectTypeClassification(memberType, target, i); } }
public static void GetObjectTypeClassification(Type objType, ExposedObjectDescriptor target, int idx) { Type unityObjectType = typeof(UnityEngine.Object); if (objType == unityObjectType || objType.IsAssignableFrom(unityObjectType) || objType.IsSubclassOf(unityObjectType)) { target.unityObjCount++; target.memberTypes[idx] = TypeClassification.unityObj; } else if (objType.IsPrimitive || objType.IsEnum || objType == typeof(string)) { target.primCount ++; target.memberTypes[idx] = TypeClassification.primitive; } else if (objType.IsArray || objType is ICollection) { target.collCount++; target.memberTypes[idx] = TypeClassification.collection; } else if (objType.IsClass || objType.IsValueType) { target.objCount++; target.memberTypes[idx] = TypeClassification.obj; } }
private static ExposedObjectDescriptor CreateObjectDescriptor(Type objType, bool allowNativeUnityComponents) { ExposedObjectDescriptor result = new ExposedObjectDescriptor(); result.isStruct = objType.IsValueType && !objType.IsClass && !objType.IsPrimitive && !objType.IsEnum; if (allowNativeUnityComponents) { result.members = CreateTypeMemberEntry( objType, vBug.settings.recording.gameObjectReflection.allowCustomClassPropertyScanning || !objType.IsSubclassOf(typeof(UnityEngine.MonoBehaviour)) ); } else { result.members = CreateTypeMemberEntry(objType, vBug.settings.recording.gameObjectReflection.allowCustomClassPropertyScanning); } SetTypeMembertypeEntry(result); result.memberNames = CreateMemberNamesEntry(result.members); result.representedType = objType.FullName; return result; }