Beispiel #1
0
        void ActivateAwakeRecursively()
        {
            AwakeFromLoadQueue queue = new AwakeFromLoadQueue();

            ActivateAwakeRecursivelyInternal(queue);
            queue.AwakeFromLoad(AwakeFromLoadMode.kActivateAwakeFromLoad);
        }
Beispiel #2
0
        void ActivateAwakeRecursivelyInternal(AwakeFromLoadQueue queue)
        {
            if (m_IsActivating)
            {
                Debug.LogError("GameObject is already being activated or deactivated.");
                return;
            }
            bool state;
            bool changed;

            m_IsActivating = true;
            if (m_IsActiveCached != -1)
            {
                bool oldState = m_IsActiveCached == 1;
                m_IsActiveCached = -1;
                state            = IsActive();
                changed          = oldState != state;
            }
            else
            {
                state   = IsActive();
                changed = true;
            }

            if (transform != null)
            {
                var count = transform.children.Count;
                for (int i = 0; i < count; i++)
                {
                    var t = transform.GetChild(i);
                    if (t != null)
                    {
                        t.gameObject.ActivateAwakeRecursivelyInternal(queue);
                    }
                }
            }

            if (changed)
            {
                for (int i = 0; i < cs.Count; i++)
                {
                    var c = cs[i];
                    if (state)
                    {
                        c.SetGameObjectInternal(this);
                        queue.Add(c);
                    }
                    else
                    {
                        c.Deactivate();
                    }
                }

                if (state)
                {
                    UpdateActiveGONode();
                }
                else
                {
                    GameObjectManager.RemoveObject(this);
                }
            }
            m_IsActivating = false;
        }