public void Activate(ManagedObject obj) { if (!activeObjects.Contains(obj)) activeObjects.Add(obj); obj.gameObject.SetActive(true); }
public static void add(IntPtr p, ManagedObject mo) { Debug.Assert(p != IntPtr.Zero); lock ( syncRoot ) { Debug.Assert(!managed.ContainsKey(p)); managed.Add(p, new WeakReference <ManagedObject>(mo)); } }
private void DrawFields(ManagedObject managedObject) { if (managedObject.typeDescription.isArray) { return; } GUILayout.Space(10); GUILayout.Label("Fields:"); DrawFields(managedObject.typeDescription, _unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation)); }
int getManagedObjHashCode(ManagedObject mao, CrawledMemorySnapshot unpacked) { var ba = unpacked.managedHeap.Find(mao.address, unpacked.virtualMachineInformation); var result = getBytesFromHeap(ba, mao.size); if (result != null && result.Length > 0) { return(result.GetHashCode() * mao.size); } return(-1); }
void _handleDiffManangeObj(ManagedObject mao, string diffType, CrawledMemorySnapshot resultPacked) { var theType = _checkNewTypes(mao, diffType); if (theType == null) { return; } MemObject item = new MemObject(mao, resultPacked); string TypeName = MemUtil.GetGroupName(mao); mao.caption = MemUtil.GetCategoryLiteral(mao) + TypeName + diffType; theType.AddObject(item); }
protected virtual void BindingEvents() { // // txtObjectName // txtObjectName.LostFocus += (sender, args) => { if (null == SelectedObject) { return; } SelectedObject.Name = ((TextBox)sender).Text; }; // // txtObjectDescription // txtObjectDescription.LostFocus += (sender, args) => { if (null == SelectedObject) { return; } SelectedObject.Description = ((TextBox)sender).Text; }; // // chkObjectDisabled // chkObjectDisabled.CheckedChanged += (sender, args) => { if (null == SelectedObject) { return; } SelectedObject.Disabled = ((CheckBox)sender).Checked; }; // // lstObject // lstObject.SelectedIndexChanged += (sender, args) => SelectedObject = ((ManagedObject)((ListBox)sender).SelectedItem).ShallowClone(); // // this // Load += (sender, args) => InitData(); //Shown += (sender, args) => //{ // OnSelectedObjectChanged(); // lstObject.Focus(); //}; }
private static List <object> DiffManaged(Dictionary <UInt64, MemObject> managed1st, Dictionary <UInt64, MemObject> managed2nd) { HashSet <UInt64> both = Intersect(managed1st, managed2nd); List <object> ret = new List <object>(); foreach (var p in managed1st) { if (!both.Contains(p.Key)) { MarkStatus(p.Value, eDiffStatus.Removed); ret.Add(p.Value); } } foreach (var p in managed2nd) { if (!both.Contains(p.Key)) { MarkStatus(p.Value, eDiffStatus.Added); ret.Add(p.Value); } } foreach (UInt64 i in both) { ManagedObject obj1 = managed1st[i]._thing as ManagedObject; ManagedObject obj2 = managed2nd[i]._thing as ManagedObject; MemObject mo = managed2nd[i]; if (obj1.size == obj2.size) { MarkStatus(mo, eDiffStatus.Unchanged); } else if (obj1.size > obj2.size) { MarkStatus(mo, eDiffStatus.Decreased); ret.Add(mo); } else { MarkStatus(mo, eDiffStatus.Increased); ret.Add(mo); } } return(ret); }
protected override void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Release managed resources. ManagedObject.Dispose(); Handle = IntPtr.Zero; } // Release unmanaged resources. ReleaseHandle(); _disposed = true; } base.Dispose(disposing); }
void PopulateObjects() { for (int i = 0; i < m_NumObjects; ++i) { m_Objects[i] = new ManagedObject(); m_Objects[i].m_Object = (GameObject)Instantiate(m_ObjectPrefab); m_Objects[i].m_Object.transform.parent = transform; m_Objects[i].m_TrailRenderer = m_Objects[i].m_Object.GetComponentInChildren <TrailRenderer>(); if (m_Objects[i].m_TrailRenderer) { m_BaseTrailTime = m_Objects[i].m_TrailRenderer.time; } m_Objects[i].m_Enabled = false; m_Objects[i].m_Object.SetActive(false); } }
public void EventThrow(ManagedObject sender, ManagedEventType e) { if (ManagedTarget) { if (ManagedTarget == sender && (e == TargetEvent || TargetEvent == ManagedEventType.OnAny)) { Debug.Log(name + " recieved managed event command " + e.ToString() + " from sender " + sender.name + "."); Trigger(); } } else if (e == TargetEvent || TargetEvent == ManagedEventType.OnAny) { Debug.Log(name + " recieved event command " + e.ToString() + " from sender " + sender.name + "."); Trigger(); } }
public void Deactivate(ManagedObject obj) { if (!activeObjects.Contains(obj)) Debug.LogError("MultipleObjectManager.Deactivate(obj) not active"); // Remove from the active list activeObjects.Remove(obj); // Destroy if over the max inactive if (inactiveObjects.Count > MaxInactiveObjects) GameObject.Destroy(obj.gameObject); else { obj.gameObject.SetActive(false); inactiveObjects.Add(obj); } }
void _handleDiffObj(ThingInMemory thing, string diffType, CrawledMemorySnapshot resultPacked) { var theType = _checkNewTypes(thing, diffType); if (theType == null) { return; } string TypeName = MemUtil.GetGroupName(thing); ThingInMemory newThings = null; if (thing is NativeUnityEngineObject) { var nat = thing as NativeUnityEngineObject; var newNat = new NativeUnityEngineObject(); newNat.caption = thing.caption; newNat.classID = nat.classID; newNat.className = TypeName + diffType; newNat.instanceID = nat.instanceID; newNat.isManager = false; newNat.size = thing.size; newNat.hideFlags = nat.hideFlags; newNat.isPersistent = nat.isPersistent; newNat.name = nat.name; newNat.referencedBy = thing.referencedBy; newNat.references = thing.references; newNat.isDontDestroyOnLoad = nat.isDontDestroyOnLoad; newThings = newNat; } else { var mao = thing as ManagedObject; var newMao = new ManagedObject(); newMao.caption = TypeName + diffType; newMao.address = mao.address; newMao.referencedBy = mao.referencedBy; newMao.references = mao.references; newMao.size = mao.size; newMao.typeDescription = mao.typeDescription; newThings = newMao; } MemObject item = new MemObject(newThings, resultPacked); theType.AddObject(item); }
public void DrawPlainData() { if (_unpackedCrawl != null) { GUILayout.Label(" "); if (GUILayout.Button("Save full list of elements data to an external .txt file")) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "SnapshotExport.txt", "txt"); if (!String.IsNullOrEmpty(exportPath)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine("Managed Objects"); for (int i = 0; i < _unpackedCrawl.managedObjects.Length; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; sw.WriteLine("Address: " + managedObject.address + ", Caption: " + managedObject.caption + ", Size: " + managedObject.size); } sw.WriteLine("Native Objects"); for (int i = 0; i < _unpackedCrawl.nativeObjects.Length; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; sw.WriteLine("InstanceID: " + nativeObject.instanceID + ", Name: " + nativeObject.name + ", Size: " + nativeObject.size); } sw.Flush(); sw.Close(); } } GUILayout.Label(" "); GUILayout.Label("Managed Objects - First 10 Elements: "); GUILayout.Label(" "); for (int i = 0; i < _unpackedCrawl.managedObjects.Length && i < 10; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; GUILayout.Label("Address: " + managedObject.address + ", Caption: " + managedObject.caption + ", Size: " + managedObject.size); } GUILayout.Label(" "); GUILayout.Label("Native Objects - First 10 Elements:"); GUILayout.Label(" "); for (int i = 0; i < _unpackedCrawl.nativeObjects.Length && i < 10; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; GUILayout.Label("InstanceID: " + nativeObject.instanceID + ", Name: " + nativeObject.name + ", Size: " + nativeObject.size); } } }
public static void ToValue(ref Value v, object o) { if (o == null) { v.Kind = Kind.NPOBJ; v.u.p = IntPtr.Zero; return; } if (o is sbyte || o is short || o is int || o is byte || o is ushort || o is uint || o is long || o is ulong || o is float || o is double || o is decimal || o.GetType().IsEnum) { v.Kind = Kind.DOUBLE; v.u.d = Convert.ToDouble(o); } else if (o is bool) { v.Kind = Kind.BOOL; v.u.i32 = ((bool)o) ? 1 : 0; } else if (o is char || o is string || o is Guid) { v.Kind = Kind.STRING; v.u.p = Value.StringToIntPtr(o.ToString()); } else if (o is DateTime) { v.Kind = Kind.DATETIME; v.u.i64 = (((DateTime)o).Ticks - new DateTime(1970, 1, 1).Ticks) / 10000; } else if (o is ScriptObject) { // FIXME: We should ref the SO here v.Kind = Kind.NPOBJ; v.u.p = ((ScriptObject)o).Handle; } else { // FIXME: We should ref the SO here v.Kind = Kind.NPOBJ; v.u.p = ManagedObject.GetManagedObject(o).Handle; } }
private IList <MemoryElement> populateData(int numTotalElements) { var treeElements = new List <MemoryElement>(numTotalElements + 1); var root = new MemoryElement("Root", -1, 0, "Root", "Root", 0f); treeElements.Add(root); if (_unpackedCrawl == null) { return(treeElements); } ThingInMemory[] tmp = _unpackedCrawl.allObjects; for (int i = 0; i < numTotalElements; ++i) { if (tmp[i] is NativeUnityEngineObject) { NativeUnityEngineObject nuo = tmp[i] as NativeUnityEngineObject; root = new MemoryElement(nuo.caption, 0, nuo.instanceID, nuo.className, "Native", tmp[i].size); } else if (tmp[i] is ManagedObject) { ManagedObject mo = tmp[i] as ManagedObject; root = new MemoryElement(mo.caption, 0, 0, "Managed", "Managed", mo.size); } else if (tmp[i] is GCHandle) { GCHandle gch = tmp[i] as GCHandle; root = new MemoryElement(gch.caption, 0, 0, "GC Handle", "GC Handle", gch.size); } else if (tmp[i] is StaticFields) { StaticFields sf = tmp[i] as StaticFields; root = new MemoryElement(sf.caption, 0, 0, "GC Handle", sf.typeDescription.name, sf.size); } root.memData = tmp[i]; treeElements.Add(root); } return(treeElements); }
public void Deactivate(ManagedObject obj) { if (!activeObjects.Contains(obj)) { Debug.LogError("MultipleObjectManager.Deactivate(obj) not active"); } // Remove from the active list activeObjects.Remove(obj); // Destroy if over the max inactive if (inactiveObjects.Count > MaxInactiveObjects) { GameObject.Destroy(obj.gameObject); } else { obj.gameObject.SetActive(false); inactiveObjects.Add(obj); } }
public override bool ReleaseManagedObject(ManagedObject <T> managedObject, bool fromOnDestroy = false) { if (!base.CheckObjectIsManaged(managedObject)) { return(false); } BoundsBasedManagedObject <S, T> boundsBaseManagedObject = managedObject as BoundsBasedManagedObject <S, T>; if (boundsBaseManagedObject == null) { return(false); } if (fromOnDestroy) { base.managedObjects.Remove(managedObject); // NOTE: // Comment out following code when refactored this. // Maybe thorwing Exception is more better for debug. // // if (boundsBaseManagedObject.BelongBoundsIndex != -1 // && boundsBaseManagedObject.BelongBoundsIndex < this.managedObjectsInBounds.Count) // { // } this.managedObjectsInBounds[boundsBaseManagedObject.BelongBoundsIndex].Remove(boundsBaseManagedObject); } else { GameObject.Destroy(managedObject); } return(true); }
protected void UpdateObjects() { //reset flag table for (int i = 0; i < m_NumObjects; ++i) { m_ObjectUpdated[i] = false; } //get particles int iNumParticles = GetComponent <ParticleSystem>().GetParticles(m_Particles); //run through the particles and look for the correlating entry in the hash map for (int i = 0; i < iNumParticles; ++i) { int iObjectIndex = -1; if (!m_ObjectParticleMap.ContainsKey(m_Particles[i].randomSeed)) { //couldn't be found-- add a new entry iObjectIndex = GetOpenIndex(); if (iObjectIndex != -1) { m_ObjectParticleMap.Add(m_Particles[i].randomSeed, iObjectIndex); } } else { iObjectIndex = m_ObjectParticleMap[m_Particles[i].randomSeed]; } if (iObjectIndex != -1) { //turn this guy on if he's new ManagedObject rObj = m_Objects[iObjectIndex]; if (!rObj.m_Enabled) { rObj.m_Object.SetActive(true); rObj.m_Enabled = true; } //set position rObj.m_Object.transform.position = m_Particles[i].position; if (rObj.m_TrailRenderer) { //update trail renderer float fToStart = m_Particles[i].startLifetime - m_Particles[i].remainingLifetime; float fToEnd = m_Particles[i].remainingLifetime; float fMinDist = Mathf.Min(Mathf.Min(fToStart, fToEnd) - 0.2f, m_BaseTrailTime); rObj.m_TrailRenderer.time = fMinDist; } //set flag for later m_ObjectUpdated[iObjectIndex] = true; } } //run through and turn off all particles that weren't updated for (int i = 0; i < m_NumObjects; ++i) { ManagedObject rObj = m_Objects[i]; if (!m_ObjectUpdated[i] && rObj.m_Enabled) { rObj.m_Object.SetActive(false); rObj.m_Enabled = false; } } }
public static bool Permit(this IAcSession user, FunctionState function, ManagedObject currentEntity) { var securityService = user.AcDomain.RetrieveRequiredService <ISecurityService>(); return(securityService.Permit(user, function, currentEntity)); }
public static bool TryChangeType(object value, Type type, CultureInfo culture, out object ret) { ret = value; if (value == null) { return(true); } if (value.GetType() == type) { return(true); } ScriptObject so = value as ScriptObject; if (so != null) { if (value.GetType().Equals(typeof(ManagedObject)) || value.GetType().Equals(typeof(ScriptObject))) { ret = so.ConvertTo(type, false); return(true); } else if (type.IsAssignableFrom(value.GetType())) { return(true); } return(false); } bool ismousebuttons = type.Equals(typeof(MouseButtons)); if (ismousebuttons) { try { int d = (int)Convert.ChangeType(value, typeof(int), culture); switch (d) { case 0: ret = MouseButtons.Left; break; case 1: ret = MouseButtons.Middle; break; case 2: ret = MouseButtons.Right; break; default: return(false); } return(true); } catch { return(false); } } if (type.IsAssignableFrom(value.GetType())) { return(true); } if (type.IsEnum) { try { ret = Enum.Parse(type, value.ToString(), true); return(true); } catch { return(false); } } if (type == typeof(Guid) && value is string) { ret = new Guid((string)value); return(true); } if (type == typeof(ScriptObject)) { ret = new ManagedObject(value); return(true); } try { ret = Convert.ChangeType(value, type, culture); return(true); } catch { switch (Type.GetTypeCode(type)) { case TypeCode.Char: case TypeCode.Byte: case TypeCode.SByte: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: case TypeCode.Single: case TypeCode.Double: ret = Convert.ChangeType(0, type, culture); return(true); case TypeCode.String: ret = ""; return(true); case TypeCode.Boolean: ret = false; return(true); } } return(false); }
internal static BluetoothDevice Create(ManagedObject managedObject) { return(new BluetoothDevice(managedObject.CreateProxy <IDevice1>(Services.Base), managedObject.GetPropertiesForInterface <Device1Properties>(Interfaces.Device1))); }
public void DrawPlainData() { if (_unpackedCrawl != null) { GUILayout.Label(" "); if (GUILayout.Button("Save full list of MANAGED objects data to an external .csv file", blueColorStyle)) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "MANAGED SnapshotExport (" + DateTime.Now.ToString("dd-MM-yyyy hh-mm-ss") + ").csv", "csv"); if (!String.IsNullOrEmpty(exportPath)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine(" Managed Objects , Size , Caption , Type , Number of References (Total), Referenced By (Total), Address "); for (int i = 0; i < _unpackedCrawl.managedObjects.Length; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; sw.WriteLine("Managed," + managedObject.size + "," + CleanStrings(managedObject.caption) + "," + CleanStrings(managedObject.typeDescription.name) + "," + managedObject.references.Length + "," + managedObject.referencedBy.Length + "," + managedObject.address); } sw.Flush(); sw.Close(); } } if (GUILayout.Button("Save full list of NATIVE objects data to an external .csv file", greenColorStyle)) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "NATIVE SnapshotExport (" + DateTime.Now.ToString("dd-MM-yyyy hh-mm-ss") + ").csv", "csv"); if (!String.IsNullOrEmpty(exportPath)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine(" Native Objects , Size , Caption , Class Name , Name , Number of References (Total), Referenced By (Total), InstanceID "); for (int i = 0; i < _unpackedCrawl.nativeObjects.Length; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; sw.WriteLine("Native," + nativeObject.size + "," + CleanStrings(nativeObject.caption) + "," + CleanStrings(nativeObject.className) + "," + CleanStrings(nativeObject.name) + "," + nativeObject.references.Length + "," + nativeObject.referencedBy.Length + "," + nativeObject.instanceID); } sw.Flush(); sw.Close(); } } if (GUILayout.Button("Save full list of All objects data to an external .csv file", redColorStyle)) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "ALL SnapshotExport (" + DateTime.Now.ToString("dd-MM-yyyy hh-mm-ss") + ").csv", "csv"); if (!String.IsNullOrEmpty(exportPath)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine(" Object , Size , Caption , Type , Number of References (Total), Referenced By (Total), Address (Managed) or InstanceID (Native) "); for (int i = 0; i < _unpackedCrawl.managedObjects.Length; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; sw.WriteLine("Managed," + managedObject.size + "," + CleanStrings(managedObject.caption) + "," + CleanStrings(managedObject.typeDescription.name) + "," + managedObject.references.Length + "," + managedObject.referencedBy.Length + "," + managedObject.address); } for (int i = 0; i < _unpackedCrawl.nativeObjects.Length; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; sw.WriteLine("Native," + nativeObject.size + "," + CleanStrings(nativeObject.caption) + "," + CleanStrings(nativeObject.className) + "," + nativeObject.references.Length + "," + nativeObject.referencedBy.Length + "," + nativeObject.instanceID); } sw.Flush(); sw.Close(); } } GUILayout.Label(" "); GUILayout.Label("Managed Objects (Total: " + _unpackedCrawl.managedObjects.Length + ") - First 10 Elements: "); GUILayout.Label(" "); for (int i = 0; i < _unpackedCrawl.managedObjects.Length && i < 10; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; GUILayout.Label("Address: " + managedObject.address + ", Caption: " + managedObject.caption + ", Size: " + managedObject.size); } GUILayout.Label(" "); GUILayout.Label("Native Objects (Total: " + _unpackedCrawl.nativeObjects.Length + ") - First 10 Elements:"); GUILayout.Label(" "); for (int i = 0; i < _unpackedCrawl.nativeObjects.Length && i < 10; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; GUILayout.Label("InstanceID: " + nativeObject.instanceID + ", Name: " + nativeObject.name + ", Size: " + nativeObject.size); } } }
int getManagedObjHashCode(ManagedObject mao) { return(mao.address.GetHashCode() + mao.size.GetHashCode()); }
public static BluetoothAdapter Create(ManagedObject managedObject) { return(new BluetoothAdapter(managedObject.CreateProxy <IAdapter1>(Services.Base), managedObject.GetPropertiesForInterface <Adapter1Properties>(Interfaces.Adapter1))); }
public void DrawPlainData() { if (_unpackedCrawl != null) { GUILayout.Label(" "); if (GUILayout.Button("Save managed heap data to an external .csv file", blueColorStyle)) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "MANAGEDHEAP_SnapshotExport_" + DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss") + ".csv", "csv"); if (!String.IsNullOrEmpty(exportPath)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine(" Managed Objects , Size , Address "); for (int i = 0; i < _unpackedCrawl.managedHeap.Length; i++) { MemorySection memorySection = _unpackedCrawl.managedHeap[i]; sw.WriteLine("Managed," + memorySection.bytes.Length + "," + memorySection.startAddress); } sw.Flush(); sw.Close(); } } if (GUILayout.Button("Save full list of MANAGED objects data to an external .csv file", blueColorStyle)) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "MANAGED_SnapshotExport_" + DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss") + ".csv", "csv"); if (!String.IsNullOrEmpty(exportPath)) { m_ManagedGroups.Clear(); System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine(" Managed Objects , Size , Caption , Type , Number of References (Total), Referenced By (Total), Address "); for (int i = 0; i < _unpackedCrawl.managedObjects.Length; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; sw.WriteLine("Managed," + managedObject.size + "," + CleanStrings(managedObject.caption) + "," + CleanStrings(managedObject.typeDescription.name) + "," + managedObject.references.Length + "," + managedObject.referencedBy.Length + "," + managedObject.address); string type = managedObject.typeDescription.name; long size = managedObject.size; ManagedGroupInfo info; if (m_ManagedGroups.TryGetValue(type, out info)) { ++info.Count; info.Size += size; } else { string g = string.Empty; int si = type.IndexOf('.'); if (si > 0) { g = type.Substring(0, si); if (!s_ManagedGroupNames.Contains(g)) { g = string.Empty; } } info = new ManagedGroupInfo { Group = g, Type = type, Count = 1, Size = size }; m_ManagedGroups.Add(type, info); } } sw.Flush(); sw.Close(); string dir = Path.GetDirectoryName(exportPath); string fn = Path.GetFileNameWithoutExtension(exportPath); string gpath = Path.Combine(dir, fn + "_groups.csv"); var lastGroup = "A000000"; using (var outsw = new StreamWriter(gpath)) { outsw.WriteLine("group,type,count,size"); foreach (var pair in m_ManagedGroups) { var info = pair.Value; var g = info.Group; if (!string.IsNullOrEmpty(lastGroup) && string.IsNullOrEmpty(info.Group)) { g = lastGroup + "__"; } if (!string.IsNullOrEmpty(info.Group)) { lastGroup = info.Group; } outsw.WriteLine("{0},\"{1}\",{2},{3}", g, info.Type, info.Count, info.Size); } } string gpath2 = Path.Combine(dir, fn + "_groups_forcmp.csv"); using (var outsw = new StreamWriter(gpath2)) { outsw.WriteLine("type,count,size"); foreach (var pair in m_ManagedGroups) { var info = pair.Value; outsw.WriteLine("\"{0}\",{1},{2}", info.Type, info.Count, info.Size); } } } } if (GUILayout.Button("Save full list of NATIVE objects data to an external .csv file", greenColorStyle)) { string exportPath = EditorUtility.SaveFilePanel("Save Snapshot Info", Application.dataPath, "NATIVE_SnapshotExport_" + DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss") + ".csv", "csv"); if (!String.IsNullOrEmpty(exportPath)) { m_NativeGroups.Clear(); System.IO.StreamWriter sw = new System.IO.StreamWriter(exportPath); sw.WriteLine(" Native Objects , Size , Caption , Class Name , Name , Number of References (Total), Referenced By (Total), InstanceID "); for (int i = 0; i < _unpackedCrawl.nativeObjects.Length; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; sw.WriteLine("Native," + nativeObject.size + "," + CleanStrings(nativeObject.caption) + "," + CleanStrings(nativeObject.className) + "," + CleanStrings(nativeObject.name) + "," + nativeObject.references.Length + "," + nativeObject.referencedBy.Length + "," + nativeObject.instanceID); string type = nativeObject.className; long size = nativeObject.size; NativeGroupInfo info; if (m_NativeGroups.TryGetValue(type, out info)) { ++info.Count; info.Size += size; } else { info = new NativeGroupInfo { Type = type, Count = 1, Size = size }; m_NativeGroups.Add(type, info); } } sw.Flush(); sw.Close(); string dir = Path.GetDirectoryName(exportPath); string fn = Path.GetFileNameWithoutExtension(exportPath); string gpath = Path.Combine(dir, fn + "_groups.csv"); using (var outsw = new StreamWriter(gpath)) { outsw.WriteLine("type,count,size"); foreach (var pair in m_NativeGroups) { var info = pair.Value; outsw.WriteLine("\"{0}\",{1},{2}", info.Type, info.Count, info.Size); } } } } GUILayout.Label(" "); GUILayout.Label("Managed Objects (Total: " + _unpackedCrawl.managedObjects.Length + ") - First 10 Elements: "); GUILayout.Label(" "); for (int i = 0; i < _unpackedCrawl.managedObjects.Length && i < 10; i++) { ManagedObject managedObject = _unpackedCrawl.managedObjects[i]; GUILayout.Label("Address: " + managedObject.address + ", Caption: " + managedObject.caption + ", Size: " + managedObject.size); } GUILayout.Label(" "); GUILayout.Label("Native Objects (Total: " + _unpackedCrawl.nativeObjects.Length + ") - First 10 Elements:"); GUILayout.Label(" "); for (int i = 0; i < _unpackedCrawl.nativeObjects.Length && i < 10; i++) { NativeUnityEngineObject nativeObject = _unpackedCrawl.nativeObjects[i]; GUILayout.Label("InstanceID: " + nativeObject.instanceID + ", Name: " + nativeObject.name + ", Size: " + nativeObject.size); } } }