Exemplo n.º 1
0
        HierarchyData CollectHierarchyData(ref bool hasNext, ref bool hasChanged, HierarchyData hd, HierarchyProperty hp)
        {
            var depth      = hp.depth;
            var name       = hp.name;
            var instanceID = hp.instanceID;

            List <HierarchyData> list = null;

            list = (hd == null || hd.children == null) ? new List <HierarchyData>() : hd.children;

            if (hp.hasChildren)
            {
                hasNext = hp.Next(null);
                var i = 0;
                while (hasNext && hp.depth > depth)
                {
                    var go = EditorUtility.InstanceIDToObject(hp.instanceID);

                    if (go == gameObject)
                    {
                        // skip children of EVR to prevent the display of EVR contents
                        while (hp.Next(null) && hp.depth > depth + 1)
                        {
                        }
                        name       = hp.name;
                        instanceID = hp.instanceID;
                    }

                    if (i >= list.Count)
                    {
                        list.Add(CollectHierarchyData(ref hasNext, ref hasChanged, null, hp));
                        hasChanged = true;
                    }
                    else if (list[i].instanceID != hp.instanceID)
                    {
                        list[i]    = CollectHierarchyData(ref hasNext, ref hasChanged, null, hp);
                        hasChanged = true;
                    }
                    else
                    {
                        list[i] = CollectHierarchyData(ref hasNext, ref hasChanged, list[i], hp);
                    }

                    if (hasNext)
                    {
                        hasNext = hp.Next(null);
                    }

                    i++;
                }

                if (i != list.Count)
                {
                    list.RemoveRange(i, list.Count - i);
                    hasChanged = true;
                }

                if (hasNext)
                {
                    hp.Previous(null);
                }
            }
            else
            {
                list.Clear();
            }

            List <HierarchyData> children = null;

            if (list.Count > 0)
            {
                children = list;
            }

            if (hd != null)
            {
                hd.children   = children;
                hd.name       = name;
                hd.instanceID = instanceID;
            }

            return(hd ?? new HierarchyData(name, instanceID, children));
        }
Exemplo n.º 2
0
        HierarchyData CollectHierarchyData(ref bool hasNext, ref bool hasChanged, HierarchyData hd, HierarchyProperty hp, HashSet <string> objectTypes)
        {
            var depth      = hp.depth;
            var name       = hp.name;
            var instanceID = hp.instanceID;
            var types      = InstanceIDToComponentTypes(instanceID, objectTypes);

            List <HierarchyData> children = null;

            if (hp.hasChildren)
            {
                if (hd != null && hd.children == null)
                {
                    hasChanged = true;
                }

                children = hd == null || hd.children == null ? new List <HierarchyData>() : hd.children;

                hasNext = hp.Next(null);
                var i = 0;
                while (hasNext && hp.depth > depth)
                {
                    var go = EditorUtility.InstanceIDToObject(hp.instanceID);

                    if (go == gameObject)
                    {
                        // skip children of EVR to prevent the display of EVR contents
                        while (hp.Next(null) && hp.depth > depth + 1)
                        {
                        }

                        // If EVR is the last object, don't add anything to the list
                        if (hp.instanceID == 0)
                        {
                            break;
                        }

                        name       = hp.name;
                        instanceID = hp.instanceID;
                        types      = InstanceIDToComponentTypes(instanceID, objectTypes);
                    }

                    if (i >= children.Count)
                    {
                        children.Add(CollectHierarchyData(ref hasNext, ref hasChanged, null, hp, objectTypes));
                        hasChanged = true;
                    }
                    else if (children[i].index != hp.instanceID)
                    {
                        children[i] = CollectHierarchyData(ref hasNext, ref hasChanged, null, hp, objectTypes);
                        hasChanged  = true;
                    }
                    else
                    {
                        children[i] = CollectHierarchyData(ref hasNext, ref hasChanged, children[i], hp, objectTypes);
                    }

                    if (hasNext)
                    {
                        hasNext = hp.Next(null);
                    }

                    i++;
                }

                if (i != children.Count)
                {
                    children.RemoveRange(i, children.Count - i);
                    hasChanged = true;
                }

                if (children.Count == 0)
                {
                    children = null;
                }

                if (hasNext)
                {
                    hp.Previous(null);
                }
            }
            else if (hd != null && hd.children != null)
            {
                hasChanged = true;
            }

            if (hd != null)
            {
                hd.children   = children;
                hd.name       = name;
                hd.instanceID = instanceID;
                hd.types      = types;
            }

            return(hd ?? new HierarchyData(name, instanceID, types, children));
        }