Example #1
0
        /*--------------------------------------------------------------------------------------------*/
        private void DescendTree(int pDepth)
        {
            if (vIsDestroyed)
            {
                return;
            }

            int childCount = TreeChildrenThisFrame.Count;
            int childDepth = pDepth + 1;

            for (int i = 0; i < childCount; i++)
            {
                TreeUpdater childTreeUp = TreeChildrenThisFrame[i];

                if (childTreeUp == null)
                {
                    if (!ReloadTreeChildrenOnUpdate)
                    {
                        ReloadTreeChildrenOnUpdate = true;
                        Debug.LogError("Lost tree child, will refresh list next frame: " + i, this);
                    }

                    continue;
                }

                if (!childTreeUp.gameObject.activeSelf)
                {
                    continue;
                }

                childTreeUp.UpdateThisLevelAndDescend(childDepth);
            }
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void FindTreeUpdatablesAndChildren()
        {
            if (TreeChildrenThisFrame.Count > 0)
            {
                TreeChildrenThisFrame.Clear();
            }

            gameObject.GetComponents(TreeUpdatablesThisFrame);

            int childCount = transform.childCount;

            for (int i = 0; i < childCount; i++)
            {
                TreeUpdater childTreeUp = transform.GetChild(i).GetComponent <TreeUpdater>();

                if (childTreeUp == null)
                {
                    continue;
                }

                TreeChildrenThisFrame.Add(childTreeUp);
            }

            //Debug.Log(Time.frameCount+" | FindTreeUpdatablesAndChildren: "+childCount+" / "+
            //	TreeChildrenThisFrame.Count, this);
        }
Example #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void HandleTreeUpdatableChanged(bool pSendDownward = true, int pDepth = 0)
        {
            int untilFrame = Time.frameCount + 1;

            if (vTreeUpdatablesRequireUpdateUntilFrame >= untilFrame)
            {
                return;
            }

            //Debug.Log(Time.frameCount+" | HandleTreeUpdatableChanged: "+pDepth+" / "+untilFrame+" / "+
            //	pSendDownward+" / "+transform.ToDebugPath(), this);

            vTreeUpdatablesRequireUpdateUntilFrame = untilFrame;
            CheckForParent();
            TreeParentThisFrame?.HandleTreeUpdatableChanged(false, pDepth - 1);

            for (int i = 0; pSendDownward && i < TreeChildrenThisFrame.Count; i++)
            {
                TreeUpdater childTreeUp = TreeChildrenThisFrame[i];

                if (childTreeUp == null || childTreeUp.gameObject.activeSelf != true)
                {
                    continue;
                }

                childTreeUp.HandleTreeUpdatableChanged(true, pDepth + 1);
            }
        }
Example #4
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void AscendTreeOrBegin(bool pFromUpdate)
        {
            //Debug.Log("AscendTreeOrBegin: "+gameObject.name, gameObject);
            Transform   parTx     = transform.parent;
            TreeUpdater parTreeUp = (parTx == null ? null : parTx.GetComponent <TreeUpdater>());

            if (parTreeUp == null || !parTreeUp.isActiveAndEnabled)
            {
                BeginAtThisTreeLevel();
                return;
            }

            parTreeUp.AscendTreeOrBegin(false);
        }
Example #5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public static bool UpdateValueWithTreeMessage <TB, TV>(this TB pSource, ref TV pOld, TV pNew,
                                                               string pNote) where TB : MonoBehaviour
        {
            if (pNew == null && pOld == null)
            {
                return(false);
            }

            if (EqualityComparer <TV> .Default.Equals(pNew, pOld))
            {
                return(false);
            }

            pOld = pNew;
            TreeUpdater.SendTreeUpdatableChanged(pSource, pNote);
            return(true);
        }
Example #6
0
        /*--------------------------------------------------------------------------------------------*/
        private void DescendTree(int pDepth)
        {
            //Debug.Log(new string('-', pDepth)+"DescendTree: "+gameObject.name, gameObject);

            if (vIsDestroyed)
            {
                return;
            }

            int childDepth = pDepth + 1;

            for (int i = 0; i < TreeChildrenThisFrame.Count; i++)
            {
                TreeUpdater childTreeUp = TreeChildrenThisFrame[i];
                childTreeUp.SendTreeUpdates(childDepth);
                childTreeUp.DescendTree(childDepth);
            }
        }
Example #7
0
        /*--------------------------------------------------------------------------------------------*/
        private void FindTreeChildren()
        {
            TreeChildrenThisFrame.Clear();

            int childCount = transform.childCount;

            for (int i = 0; i < childCount; i++)
            {
                Transform   childTx     = transform.GetChild(i);
                TreeUpdater childTreeUp = childTx.GetComponent <TreeUpdater>();

                if (childTreeUp == null)
                {
                    continue;
                }

                childTreeUp.TreeParentThisFrame = this;
                TreeChildrenThisFrame.Add(childTreeUp);
            }
        }
 /*--------------------------------------------------------------------------------------------*/
 public virtual void OnValidate()           //editor only
 {
     TreeUpdater.SendTreeUpdatableChanged(this, "OnValidate");
 }
 /*--------------------------------------------------------------------------------------------*/
 public virtual void OnDisable()
 {
     TreeUpdater.SendTreeUpdatableChanged(this, "OnDisabled");
 }