void AddType(PropertyGridItem.BuildChildrenArgs args) { var target = args.parent; var type = args.type; var address = args.address; var reader = args.memoryReader; var addStatic = reader is StaticMemoryReader; var addInstance = !addStatic; if (target.depth > 64) { Debug.LogFormat("recursive reference found? type: {0}", type.name); return; } // Add the base class, if any, to the tree. if (type.isDerivedReferenceType && !type.isArray) { var baseType = m_Snapshot.managedTypes[type.baseOrElementTypeIndex]; var isSystemObject = baseType.managedTypesArrayIndex == m_Snapshot.coreTypes.systemObject; if (!isSystemObject && PackedManagedTypeUtility.HasTypeOrBaseAnyField(m_Snapshot, baseType, !addStatic, addStatic)) { var item = new BaseClassPropertyGridItem(this, m_Snapshot, address, reader) { depth = target.depth + 1, type = baseType }; item.Initialize(); target.AddChild(item); } } // Array if (type.isArray) { // Normally the baseOrElementTypeIndex of an array represents the element type. // If inspecting static generic fields though, there is no element type available for '_EmptyArray'. // class ArrayList<T> // { // static readonly T[] _EmptyArray = new T[0]; // } if (type.baseOrElementTypeIndex == -1) { return; } var pointer = address; var item = new ArrayPropertyGridItem(this, m_Snapshot, pointer, reader) { depth = target.depth + 1, type = type, displayName = type.name, }; item.Initialize(); target.AddChild(item); return; } for (var n = 0; n < type.fields.Length; ++n) { if (type.fields[n].isStatic && !addStatic) { continue; } if (!type.fields[n].isStatic && !addInstance) { continue; } var fieldType = m_Snapshot.managedTypes[type.fields[n].managedTypesArrayIndex]; // Array if (fieldType.isArray) { if (fieldType.baseOrElementTypeIndex == -1) { continue; } var pointer = reader.ReadPointer(address + (ulong)type.fields[n].offset); var item = new ArrayPropertyGridItem(this, m_Snapshot, pointer, new MemoryReader(m_Snapshot)) { depth = target.depth + 1, type = fieldType, displayName = type.fields[n].name }; item.Initialize(); target.AddChild(item); continue; } // Primitive types and types derived from System.Enum if (fieldType.isValueType && (fieldType.isPrimitive || m_Snapshot.IsEnum(fieldType))) { var item = new PrimitiveTypePropertyGridItem(this, m_Snapshot, address + (ulong)type.fields[n].offset, reader) { depth = target.depth + 1, field = type.fields[n] }; item.Initialize(); target.AddChild(item); continue; } // Value types if (fieldType.isValueType) { var item = new ValueTypePropertyGridItem(this, m_Snapshot, address + (ulong)type.fields[n].offset, reader) { depth = target.depth + 1, field = type.fields[n] }; item.Initialize(); target.AddChild(item); continue; } // Reference types //if (fieldType.isPointer) { var item = new ReferenceTypePropertyGridItem(this, m_Snapshot, address + (ulong)type.fields[n].offset, reader) { depth = target.depth + 1, field = type.fields[n] }; item.Initialize(); target.AddChild(item); continue; } } }