public int GetUnifiedIndexFrom(CachedSnapshot snapshot) { switch (connectionType) { case ConnectionType.ManagedObject_To_ManagedObject: return(snapshot.ManagedObjectIndexToUnifiedObjectIndex(index0)); case ConnectionType.ManagedType_To_ManagedObject: return(index0); case ConnectionType.UnityEngineObject: return(snapshot.NativeObjectIndexToUnifiedObjectIndex(index0)); default: return(-1); } }
public int GetUnifiedObjectIndex(CachedSnapshot snapshot) { switch (dataType) { case ObjectDataType.Array: case ObjectDataType.Object: case ObjectDataType.BoxedValue: { int idx; if (snapshot.CrawledData.MangedObjectIndexByAddress.TryGetValue(m_data.managed.objectPtr, out idx)) { return(snapshot.ManagedObjectIndexToUnifiedObjectIndex(idx)); } break; } case ObjectDataType.NativeObject: return(snapshot.NativeObjectIndexToUnifiedObjectIndex(m_data.native.index)); } return(-1); }
public static ObjectData[] GetAllObjectConnectingTo(CachedSnapshot snapshot, ObjectData obj) { var o = new List <ObjectData>(); int objIndex = -1; switch (obj.dataType) { case ObjectDataType.Array: case ObjectDataType.BoxedValue: case ObjectDataType.Object: { ManagedObjectInfo moi; if (snapshot.CrawledData.ManagedObjectByAddress.TryGetValue(obj.hostManagedObjectPtr, out moi)) { objIndex = snapshot.ManagedObjectIndexToUnifiedObjectIndex(moi.ManagedObjectIndex); //add crawled connections for (int i = 0; i != snapshot.CrawledData.Connections.Count; ++i) { var c = snapshot.CrawledData.Connections[i]; switch (c.connectionType) { case ManagedConnection.ConnectionType.Global_To_ManagedObject: if (c.toManagedObjectIndex == moi.ManagedObjectIndex) { o.Add(ObjectData.global); } break; case ManagedConnection.ConnectionType.ManagedObject_To_ManagedObject: if (c.toManagedObjectIndex == moi.ManagedObjectIndex) { var objParent = ObjectData.FromManagedObjectIndex(snapshot, c.fromManagedObjectIndex); if (c.fieldFrom >= 0) { if (objParent.dataType == ObjectDataType.Array || objParent.dataType == ObjectDataType.ReferenceArray) { o.Add(objParent); } else { o.Add(objParent.GetInstanceFieldBySnapshotFieldIndex(snapshot, c.fieldFrom, false)); } } else if (c.arrayIndexFrom >= 0) { o.Add(objParent.GetArrayElement(snapshot, c.arrayIndexFrom, false)); } else { o.Add(objParent); } } break; case ManagedConnection.ConnectionType.ManagedType_To_ManagedObject: if (c.toManagedObjectIndex == moi.ManagedObjectIndex) { var objType = ObjectData.FromManagedType(snapshot, c.fromManagedType); if (c.fieldFrom >= 0) { o.Add(objType.GetInstanceFieldBySnapshotFieldIndex(snapshot, c.fieldFrom, false)); } else if (c.arrayIndexFrom >= 0) { o.Add(objType.GetArrayElement(snapshot, c.arrayIndexFrom, false)); } else { o.Add(objType); } } break; case ManagedConnection.ConnectionType.UnityEngineObject: if (c.UnityEngineManagedObjectIndex == moi.ManagedObjectIndex) { o.Add(ObjectData.FromNativeObjectIndex(snapshot, c.UnityEngineNativeObjectIndex)); } break; } } } break; } case ObjectDataType.NativeObject: objIndex = snapshot.NativeObjectIndexToUnifiedObjectIndex(obj.nativeObjectIndex); //add crawled connection for (int i = 0; i != snapshot.CrawledData.Connections.Count; ++i) { switch (snapshot.CrawledData.Connections[i].connectionType) { case ManagedConnection.ConnectionType.Global_To_ManagedObject: case ManagedConnection.ConnectionType.ManagedObject_To_ManagedObject: case ManagedConnection.ConnectionType.ManagedType_To_ManagedObject: break; case ManagedConnection.ConnectionType.UnityEngineObject: if (snapshot.CrawledData.Connections[i].UnityEngineNativeObjectIndex == obj.nativeObjectIndex) { o.Add(ObjectData.FromManagedObjectIndex(snapshot, snapshot.CrawledData.Connections[i].UnityEngineManagedObjectIndex)); } break; } } break; default: return(null); } //add connections from the raw snapshot if (objIndex >= 0) { for (int i = 0; i != snapshot.connections.Count; ++i) { if (snapshot.connections.to[i] == objIndex) { o.Add(ObjectData.FromUnifiedObjectIndex(snapshot, snapshot.connections.from[i])); } } } return(o.ToArray()); }