public static MemoryElement GetTreeRoot(ObjectMemoryInfo[] memoryObjectList, int[] referencesIndices) { ObjectInfo[] objectInfoArray = new ObjectInfo[memoryObjectList.Length]; for (int index = 0; index < memoryObjectList.Length; ++index) objectInfoArray[index] = new ObjectInfo() { instanceId = memoryObjectList[index].instanceId, memorySize = memoryObjectList[index].memorySize, reason = memoryObjectList[index].reason, name = memoryObjectList[index].name, className = memoryObjectList[index].className }; int num = 0; for (int index1 = 0; index1 < memoryObjectList.Length; ++index1) { for (int index2 = 0; index2 < memoryObjectList[index1].count; ++index2) { int referencesIndex = referencesIndices[index2 + num]; if (objectInfoArray[referencesIndex].referencedBy == null) objectInfoArray[referencesIndex].referencedBy = new List<ObjectInfo>(); objectInfoArray[referencesIndex].referencedBy.Add(objectInfoArray[index1]); } num += memoryObjectList[index1].count; } MemoryElement memoryElement = new MemoryElement(); Array.Sort<ObjectInfo>(objectInfoArray, new Comparison<ObjectInfo>(MemoryElementDataManager.SortByMemoryClassName)); memoryElement.AddChild(new MemoryElement("Scene Memory", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.Scene))); memoryElement.AddChild(new MemoryElement("Assets", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.Asset))); memoryElement.AddChild(new MemoryElement("Builtin Resources", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.BuiltinResource))); memoryElement.AddChild(new MemoryElement("Not Saved", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.DontSave))); memoryElement.AddChild(new MemoryElement("Other", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.Other))); memoryElement.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize)); return memoryElement; }
public static MemoryElement GetTreeRoot(ObjectMemoryInfo[] memoryObjectList, int[] referencesIndices) { UnityEditor.ObjectInfo[] array = new UnityEditor.ObjectInfo[memoryObjectList.Length]; for (int i = 0; i < memoryObjectList.Length; i++) { array[i] = new UnityEditor.ObjectInfo { instanceId = memoryObjectList[i].instanceId, memorySize = memoryObjectList[i].memorySize, reason = memoryObjectList[i].reason, name = memoryObjectList[i].name, className = memoryObjectList[i].className }; } int num2 = 0; for (int j = 0; j < memoryObjectList.Length; j++) { for (int k = 0; k < memoryObjectList[j].count; k++) { int index = referencesIndices[k + num2]; if (array[index].referencedBy == null) { array[index].referencedBy = new List<UnityEditor.ObjectInfo>(); } array[index].referencedBy.Add(array[j]); } num2 += memoryObjectList[j].count; } MemoryElement element = new MemoryElement(); Array.Sort<UnityEditor.ObjectInfo>(array, new Comparison<UnityEditor.ObjectInfo>(MemoryElementDataManager.SortByMemoryClassName)); element.AddChild(new MemoryElement("Scene Memory", GenerateObjectTypeGroups(array, ObjectTypeFilter.Scene))); element.AddChild(new MemoryElement("Assets", GenerateObjectTypeGroups(array, ObjectTypeFilter.Asset))); element.AddChild(new MemoryElement("Builtin Resources", GenerateObjectTypeGroups(array, ObjectTypeFilter.BuiltinResource))); element.AddChild(new MemoryElement("Not Saved", GenerateObjectTypeGroups(array, ObjectTypeFilter.DontSave))); element.AddChild(new MemoryElement("Other", GenerateObjectTypeGroups(array, ObjectTypeFilter.Other))); element.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize)); return element; }
private static void SetMemoryProfilerInfo(ObjectMemoryInfo[] memoryInfo, int[] referencedIndices) { foreach (ProfilerWindow window in m_ProfilerWindows) { if (window.wantsMemoryRefresh) { window.m_MemoryListView.SetRoot(MemoryElementDataManager.GetTreeRoot(memoryInfo, referencedIndices)); } } }
private static void SetMemoryProfilerInfo(ObjectMemoryInfo[] memoryInfo, int[] referencedIndices) { using (List<ProfilerWindow>.Enumerator enumerator = ProfilerWindow.m_ProfilerWindows.GetEnumerator()) { while (enumerator.MoveNext()) { ProfilerWindow current = enumerator.Current; if (current.wantsMemoryRefresh) current.m_MemoryListView.SetRoot(MemoryElementDataManager.GetTreeRoot(memoryInfo, referencedIndices)); } } }