private void SelectElements(HierarchyObjectElementV2 hierarchyObjectElement)
        {
            if (!canSelectDropdownElements && hierarchyObjectElement.isDropdownElement)
            {
                return;
            }
            else
            {
            }

            if (allowMultiElementSelection)
            {
                //allow a multiselection click
            }
            else
            {
                for (int i = 0; i < _selectedElements.Count; i++)
                {
                    _selectedElements[i].isSelected = false;
                }
                _selectedElements.Clear();

                hierarchyObjectElement.isSelected = true;

                _selectedElements.Add(hierarchyObjectElement);
            }
        }
 //Update all the children of a specific element
 public void UpdateChildrenElements(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     for (int i = 0; i < hierarchyObjectElement.hierarchyObjectElements.Count; i++)
     {
         UpdateCompleteElement(hierarchyObjectElement);
     }
 }
 public void CallEventOnElementSelected(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     if (onElementSelected != null)
     {
         onElementSelected.Invoke(hierarchyObjectElement);
     }
 }
 //Some things have not been implimented fully!
 #region Remove HierarchyObjectV2 Methods
 public void RemoveHierarchyObjectWithoutUpdate(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     BufferHierarchyBranch(hierarchyObjectElement);
     if (hierarchyObjectElement.rootElement != null)
     {
         hierarchyObjectElement.rootElement.RemoveHeirarchyElement(hierarchyObjectElement);
     }
 }
Exemplo n.º 5
0
 public void RemoveHeirarchyElement(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     _hierarchyObjectElements.Remove(hierarchyObjectElement);
     hierarchyObjectElement._siblingIndex = 0;
     hierarchyObjectElement.rectTransform.SetParent(null);
     hierarchyObjectElement._rootElement = null;
     hierarchyObjectElement._depthIndex  = 0;
     //hierarchyElement.GetComponent<RectTransform>().SetParent(rectTransform);
 }
        //Places the element in the correct child spot inside its root element (Must be an element with a root element)
        public void UpdateElementPosition(HierarchyObjectElementV2 hierarchyObjectElement)
        {
            float heightOffset = hierarchyObjectElement.rootElement.rectTransform.sizeDelta.y / 2.0f - hierarchyBaseElement.hierarchyElementsHeight / 2.0f;

            for (int i = 0; i < hierarchyObjectElement.siblingIndex; i++)
            {
                heightOffset -= hierarchyObjectElement.rootElement.hierarchyObjectElements[i].rectTransform.sizeDelta.y;
            }
            hierarchyObjectElement.rectTransform.localPosition = new Vector2(0, heightOffset - hierarchyObjectElement.rectTransform.sizeDelta.y / 2.0f - hierarchyBaseElement.hierarchyElementsHeight / 2.0f);
        }
 private void BufferHierarchyBranch(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     for (int i = hierarchyObjectElement.hierarchyObjectElements.Count - 1; i >= 0; i--)
     {
         BufferHierarchyBranch(hierarchyObjectElement.hierarchyObjectElements[0]);
         hierarchyObjectElement.RemoveHeirarchyElement(hierarchyObjectElement.hierarchyObjectElements[0]);
     }
     hierarchyElementArchetypeBuffer[hierarchyObjectElement.bufferedHierarchyType].bufferedHierarchyObjectElements.Buffer(hierarchyObjectElement.bufferedHierarchyObjectElement);
     bufferedHierarchyTabElements.BufferRange(hierarchyObjectElement.ClearTabElements());
 }
Exemplo n.º 8
0
        public void AddHeirarchyElement(HierarchyObjectElementV2 hierarchyObjectElement)
        {
            hierarchyObjectElement._siblingIndex = _hierarchyObjectElements.Count;
            _hierarchyObjectElements.Add(hierarchyObjectElement);
            hierarchyObjectElement.rectTransform.SetParent(rectTransform);
            hierarchyObjectElement._rootElement = this;
            hierarchyObjectElement._depthIndex  = _depthIndex + 1;

            //Debug.Log("ADDED A CHILD", hierarchyObjectElement);

            //UpdateElementHeight();
        }
        //Updates this element and all its roots
        public void UpdateHierarchyBranch(HierarchyObjectElementV2 hierarchyObjectElement)
        {
            HierarchyObjectElementV2 childHierarchyObjectElement = hierarchyObjectElement;

            for (int i = 0; i < hierarchyObjectElement.depthIndex + 1; i++)
            {
                childHierarchyObjectElement.UpdateElementHeight();

                childHierarchyObjectElement.rectTransform.sizeDelta = new Vector2(_rect.width, childHierarchyObjectElement.fullElementHeight);

                childHierarchyObjectElement = childHierarchyObjectElement.rootElement;
            }
        }
 public void RemoveHierarchyObject(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     RemoveHierarchyObjectWithoutUpdate(hierarchyObjectElement);
     if (hierarchyObjectElement.rootElement != null)
     {
         hierarchyContentElement.UpdateHierarchyBranch(hierarchyObjectElement.rootElement);
     }
     else
     {
         Debug.LogError("THIS HAS NOT BEEN IMPLIMENTED");
         //remove the base hierarchyObject and then call hierarhcyEleme.UpdateRootElements
     }
 }
        //Cannot call on an element that is a root element of the hierarchy
        private void UpdateCompleteElement(HierarchyObjectElementV2 hierarchyObjectElement)
        {
            float heightOffset = hierarchyObjectElement.rectTransform.sizeDelta.y / 2.0f - hierarchyBaseElement.hierarchyElementsHeight / 2.0f;

            hierarchyObjectElement.labelRectTransform.localPosition = new Vector2(0, heightOffset);

            for (int i = 0; i < hierarchyObjectElement.hierarchyObjectElements.Count; i++)
            {
                hierarchyObjectElement.hierarchyObjectElements[i].rectTransform.localPosition = new Vector2(0, heightOffset - hierarchyObjectElement.hierarchyObjectElements[i].rectTransform.sizeDelta.y / 2.0f - hierarchyBaseElement.hierarchyElementsHeight / 2.0f);
                heightOffset -= hierarchyObjectElement.hierarchyObjectElements[i].rectTransform.sizeDelta.y;

                UpdateCompleteElement(hierarchyObjectElement.hierarchyObjectElements[i]);
            }
        }
        private IEnumerator UpdateHierarchyBranch(HierarchyObjectElementV2 hierarchyObjectElement)
        {
            List <HierarchyObjectElementV2> expandingElements = new List <HierarchyObjectElementV2>();

            expandingElements.Add(hierarchyObjectElement);
            GetRootElement(hierarchyObjectElement);

            void GetRootElement(HierarchyObjectElementV2 element)
            {
                if (element.rootElement != null)
                {
                    expandingElements.Add(element.rootElement);
                    GetRootElement(element.rootElement);
                }
            }

            for (int i = 0; i < expandingElements.Count; i++)
            {
                expandingElements[i].UpdateElementHeight();
            }

            for (int i = expandingElements.Count - 1; i >= 0; i--)
            {
                LayoutRebuilder.ForceRebuildLayoutImmediate(expandingElements[i].rectTransform);
            }

            while (expandingElements.Count > 0)
            {
                for (int i = expandingElements.Count - 1; i >= 0; i--)
                {
                    var sizeDelta = expandingElements[i].rectTransform.sizeDelta;
                    expandingElements[i].rectTransform.sizeDelta = Vector2.Lerp(sizeDelta, expandingElements[i].desiredSize, hierarchyAnimationValues.hierarchyListOpenSpeed);

                    if (Mathf.Abs(sizeDelta.y - expandingElements[i].desiredSize.y) < 0.5f)
                    {
                        expandingElements[i].rectTransform.sizeDelta = expandingElements[i].desiredSize;
                        expandingElements.RemoveAt(i);
                    }
                }

                UpdateHierarchyLayoutElements();

                yield return(new WaitForFixedUpdate());
            }
        }
        public HierarchyObjectElementV2 AddHierarchyObject(HierarchyObjectV2 hierarchyObject, HierarchyObjectElementV2 parent, int siblingIndex)
        {
            var hierarchyObjectElement = AddHierarchyObjectWithoutUpdate(hierarchyObject, parent, siblingIndex);

            //Cannot use this function as even though this places the Object correctly while being more optmised than updating all children elements
            //If the update is being is being optimised by calling AddHierarchyObjectWithoutUpdate, when finally calling AddHierarchyObject, the objects called WithoutUpdate would be missplaced
            //hierarchyBaseElement.hierarchyContentElement.UpdateElementPosition(hierarchyObjectElement);

            hierarchyContentElement.UpdateChildrenElements(parent);
            hierarchyContentElement.UpdateHierarchyBranch(parent);
            if (parent.isExpanded)
            {
                hierarchyContentElement.UpdateRootElements();
            }
            return(hierarchyObjectElement);
        }
        public HierarchyObjectElementV2 AddHierarchyObjectWithoutUpdate(HierarchyObjectV2 hierarchyObject, HierarchyObjectElementV2 parent, int siblingIndex)
        {
            var hierarchyObjectElement = CreateHierarchy(hierarchyObject, parent.depthIndex + 1);

            if (parent.hierarchyObjectElements.Count == 0)
            {
                parent.enableArrowElement = true;
            }
            parent.AddHeirarchyElement(hierarchyObjectElement);
            hierarchyObjectElement.SetSiblingIndex(siblingIndex);

            return(hierarchyObjectElement);
        }
 public void EnableHierarchyBranch(HierarchyObjectElementV2 hierarchyObjectElement)
 {
     StartCoroutine(UpdateHierarchyBranch(hierarchyObjectElement));
 }
 public BufferedHierarchyObjectElementV2(GameObject gameObject) : base(gameObject)
 {
     hierarchyObjectElement = gameObject.GetComponent <HierarchyObjectElementV2>();
 }