Example #1
0
        internal static void SetGlobalIndex(Transform objectTransform, Transform directParentTransform, out UIDocumentHierarchicalIndex globalIndex)
        {
            if (objectTransform == null)
            {
                globalIndex.pathToParent = null;
                return;
            }

            if (directParentTransform == null)
            {
                globalIndex.pathToParent = new int[] { objectTransform.GetSiblingIndex() };
            }
            else
            {
                List <int> pathToParent = new List <int>()
                {
                    objectTransform.GetSiblingIndex()
                };
                while (directParentTransform != null)
                {
                    pathToParent.Add(directParentTransform.GetSiblingIndex());
                    directParentTransform = directParentTransform.parent;
                }

                pathToParent.Reverse();
                globalIndex.pathToParent = pathToParent.ToArray();
            }
        }
Example #2
0
        internal static void SetHierarchicalIndex(Transform childTransform, Transform directParentTransform, Transform mainParentTransform, out UIDocumentHierarchicalIndex hierarchicalIndex)
        {
            if (mainParentTransform == null || childTransform == null)
            {
                hierarchicalIndex.pathToParent = null;
                return;
            }

            if (directParentTransform == mainParentTransform)
            {
                hierarchicalIndex.pathToParent = new int[] { childTransform.GetSiblingIndex() };
            }
            else
            {
                List <int> pathToParent = new List <int>();
                while (mainParentTransform != childTransform && childTransform != null)
                {
                    pathToParent.Add(childTransform.GetSiblingIndex());
                    childTransform = childTransform.parent;
                }

                pathToParent.Reverse();
                hierarchicalIndex.pathToParent = pathToParent.ToArray();
            }
        }