Пример #1
0
        public T AddLogic <T> () where T : LogicBase
        {
            var go = new GameObject();

            go.name = typeof(T).ToString();
            T t = go.AddComponent <T> ();

            m_currentLogic = t;
            go.transform.SetParent(transform);

            t.LogicInit();
            t.LogicShow();
            return(t);
        }
Пример #2
0
        public T GetLogic <T> () where T : LogicBase
        {
            Transform logicTran = transform.Find(typeof(T).ToString());

            if (logicTran != null)
            {
                T t = logicTran.GetComponent <T> ();
                m_currentLogic = t;
                t.LogicShow();
                return(t);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        public T OpenLogic <T> () where T : LogicBase
        {
            if (m_currentLogic != null)
            {
                m_currentLogic.LogicClose();
                m_currentLogic = null;
            }

            T t = null;

            t = GetLogic <T> ();
            if (t == null)
            {
                t = AddLogic <T> ();
            }

            return(t);
        }