Пример #1
0
        /// <summary>
        /// Registers the U.
        /// </summary>
        /// <param name="type">Type.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>

        /*
         * public void RegisterUI<T>(UIType id) where T : IUIBase
         * {
         * var type = typeof(T);
         * _dict.Add((int)id, type);
         * }
         */
        protected void RegisterUI(UIType id)
        {
            string classname = id.ToString().Insert(2, "_");

            System.Type type = System.Type.GetType("GameUI." + classname);
            _dict.Add((int)id, type);
        }
        // System.Func<UIType, int> callbackToGetWorkingInventorySlot;
        // public void SetGetWorkingInventorySlotCallback (System.Func<UIType, int> callback) {
        //     callbackToGetWorkingInventorySlot = callback;
        // }

        bool CheckForAlternateCallback(UIType type)
        {
            if (callbackToGetAlternativeSubmit == null)
            {
                Debug.LogError("cant open " + type.ToString() + " UI, no callbackToGetAlternativeSubmit supplied");
                return(false);
            }
            return(true);
        }
Пример #3
0
 /// <summary>
 /// User interfaces the register.
 /// </summary>
 protected void RegisterUIs()
 {
     // 遍历所有UI预制体,并注册
     foreach (int node in System.Enum.GetValues(typeof(UIType)))
     {
         UIType      type = (UIType)node;
         System.Type c    = System.Type.GetType(type.ToString().Insert(2, "_"));
         RegisterUI(type);
     }
 }