Example #1
0
    // =================================================================================================================================
    // Check if the hierarchy has changed since the last check
    protected bool CheckHierarchyChanges()
    {
        if (!MonitorHierarchy)
        {
            return(false);
        }

        GameObject[] tmpHierarchy = GameObjectBoundaries.GetAllChilds(transform.gameObject).ToArray();

        if (lastHierarchy.Length != tmpHierarchy.Length)
        {
            BuildStructure();
            lastHierarchy = tmpHierarchy;
            return(true);
        }

        for (int i = 0; i < tmpHierarchy.Length; i++)
        {
            if (lastHierarchy [i] != tmpHierarchy [i])
            {
                BuildStructure();
                lastHierarchy = tmpHierarchy;
                return(true);
            }
        }

        return(false);
    }
Example #2
0
    // ===================================
    // ...
    protected void UpdateChildren()
    {
        lastHierarchy = GameObjectBoundaries.GetAllChilds(transform.gameObject).ToArray();

        for (int i = 0; i < lastHierarchy.Length; i++)
        {
            if (lastHierarchy [i] != gameObject)
            {
                MetaCgoChild tmpChildComp = lastHierarchy [i].GetComponent <MetaCgoChild> ();

                if (tmpChildComp == null)
                {
                    tmpChildComp = lastHierarchy [i].AddComponent <MetaCgoChild> ();
                    tmpChildComp.MonitorPosition = MonitorChildrenPosition;
                    tmpChildComp.MonitorRotation = MonitorChildrenRotation;
                    tmpChildComp.MonitorScale    = MonitorChildrenScale;
                    tmpChildComp.UltimateParent  = this;
                }
            }
        }
    }