Пример #1
0
        /// <summary>
        /// Create the runtime lists of nodes.
        /// </summary>
        void CreateRuntimeListsOfNodes () {
            // iterator
            int i;

            // OnEnable Nodes
            var onEnableList = new List<ActionNode>();
            
            for (i = 0; i < m_Nodes.Length; i++) {
                if (!(m_Nodes[i] is Update))
                    onEnableList.Add(m_Nodes[i]);
                else
                    break;
            }

            if (onEnableList.Count > 0) {
                m_OnEnable = ActionNode.CreateInstance(typeof(OnEnable), gameObject, this) as OnEnable;
                m_OnEnable.SetChildren(onEnableList.ToArray());
            }
            else
                m_OnEnable = null;

            // Update Nodes
            var updateList = new List<ActionNode>();
            // FixedUpdate Nodes
            var fixedUpdateList = new List<ActionNode>();
            // GUI Nodes
            var onGuiList = new List<ActionNode>();

            for (int j = i + 1; j < m_Nodes.Length; j++) {

                // OnGUI
                if (m_Nodes[j] is IGUINode) {
                    onGuiList.Add(m_Nodes[j]);
                }
                // FixedUpdate
                else if (m_Nodes[j] is IFixedUpdateNode) {
                    fixedUpdateList.Add(m_Nodes[j]);
                }
                // Update
                else {
                    updateList.Add(m_Nodes[j]);
                }
            }

            // FixedUpdate
            if (fixedUpdateList.Count > 0) {
                m_FixedUpdate = ActionNode.CreateInstance(typeof(FixedUpdate), gameObject, this) as FixedUpdate;
                // Call Reset if it's not in editor
                if (!Application.isEditor)
                    m_FixedUpdate.Reset();

                m_FixedUpdate.SetChildren(fixedUpdateList.ToArray());
            }
            else
                m_FixedUpdate = null;

            // Update
            if (updateList.Count > 0) {
                m_Update = ActionNode.CreateInstance(typeof(Update), gameObject, this) as Update;
                // Call Reset if it's not in editor
                if (!Application.isEditor)
                    m_Update.Reset();

                m_Update.SetChildren(updateList.ToArray());
            }
            else
                m_Update = null;

            // OnGUI
            if (onGuiList.Count > 0) {
                m_OnGUI = ActionNode.CreateInstance(typeof(OnGUI), gameObject, this) as OnGUI;
                // Call Reset if it's not in editor
                if (!Application.isEditor)
                    m_OnGUI.Reset();
                    
                m_OnGUI.SetChildren(onGuiList.ToArray());
            }
            else
                m_OnGUI = null;
        }
Пример #2
0
        /// <summary>
        /// Create the runtime lists of nodes.
        /// </summary>
        void CreateRuntimeListsOfNodes()
        {
            // iterator
            int i;

            // OnEnable Nodes
            var onEnableList = new List <ActionNode>();

            for (i = 0; i < m_Nodes.Length; i++)
            {
                if (!(m_Nodes[i] is Update))
                {
                    onEnableList.Add(m_Nodes[i]);
                }
                else
                {
                    break;
                }
            }

            if (onEnableList.Count > 0)
            {
                m_OnEnable = ActionNode.CreateInstance(typeof(OnEnable), gameObject, this) as OnEnable;
                m_OnEnable.SetChildren(onEnableList.ToArray());
            }
            else
            {
                m_OnEnable = null;
            }

            // Update Nodes
            var updateList = new List <ActionNode>();
            // FixedUpdate Nodes
            var fixedUpdateList = new List <ActionNode>();
            // GUI Nodes
            var onGuiList = new List <ActionNode>();

            for (int j = i + 1; j < m_Nodes.Length; j++)
            {
                // OnGUI
                if (m_Nodes[j] is IGUINode)
                {
                    onGuiList.Add(m_Nodes[j]);
                }
                // FixedUpdate
                else if (m_Nodes[j] is IFixedUpdateNode)
                {
                    fixedUpdateList.Add(m_Nodes[j]);
                }
                // Update
                else
                {
                    updateList.Add(m_Nodes[j]);
                }
            }

            // FixedUpdate
            if (fixedUpdateList.Count > 0)
            {
                m_FixedUpdate = ActionNode.CreateInstance(typeof(FixedUpdate), gameObject, this) as FixedUpdate;
                // Call Reset if it's not in editor
                if (!Application.isEditor)
                {
                    m_FixedUpdate.Reset();
                }

                m_FixedUpdate.SetChildren(fixedUpdateList.ToArray());
            }
            else
            {
                m_FixedUpdate = null;
            }

            // Update
            if (updateList.Count > 0)
            {
                m_Update = ActionNode.CreateInstance(typeof(Update), gameObject, this) as Update;
                // Call Reset if it's not in editor
                if (!Application.isEditor)
                {
                    m_Update.Reset();
                }

                m_Update.SetChildren(updateList.ToArray());
            }
            else
            {
                m_Update = null;
            }

            // OnGUI
            if (onGuiList.Count > 0)
            {
                m_OnGUI = ActionNode.CreateInstance(typeof(OnGUI), gameObject, this) as OnGUI;
                // Call Reset if it's not in editor
                if (!Application.isEditor)
                {
                    m_OnGUI.Reset();
                }

                m_OnGUI.SetChildren(onGuiList.ToArray());
            }
            else
            {
                m_OnGUI = null;
            }
        }