UnityEditor.MemoryElement.AddChild C# (CSharp) Method

AddChild() public method

public AddChild ( MemoryElement node ) : void
node MemoryElement
return void
        public void AddChild(MemoryElement node)
        {
            if (node == this)
            {
                throw new Exception("Should not AddChild to itself");
            }
            this.children.Add(node);
            node.parent = this;
            this.totalMemory += node.totalMemory;
            this.totalChildCount += node.totalChildCount;
        }

Usage Example

        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);
        }
All Usage Examples Of UnityEditor.MemoryElement::AddChild