Exemplo n.º 1
0
        /// <summary>
        /// 同步创建Fairygui对象
        /// </summary>
        /// <param name="type"></param>
        /// <param name="createObjectCallback">回调</param>
        /// <param name="list">列表容器</param>
        public void CreateInstanceSync(System.Type type, FairyGUI.UIPackage.CreateObjectCallback createObjectCallback, bool fromPool = false, FairyGUI.GList list = null)
        {
#if _CREATE_INSTANCE
            var createInstanceAsyncMethod = type.GetMethod("CreateInstance", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
            createInstanceAsyncMethod.Invoke(null, new object[] {
                createObjectCallback
            });
#else
            var pakAtt           = GetPakIDAttFromType(type);
            var packageName      = pakAtt.Name;
            var itemName         = type.Name;
            FairyGUI.GObject obj = null;
#if _CREATE_LISTITEM_FROMPOOL_
            if (fromPool && list != null)
            {
                string url = string.Concat("ui://", packageName, "/", itemName);
                obj = list.itemPool.GetObject(url);
                createObjectCallback(obj);
            }
            else
            {
                obj = FairyGUI.UIPackage.CreateObject(packageName, itemName);
                createObjectCallback(obj);
            }
#else
            obj = FairyGUI.UIPackage.CreateObject(packageName, itemName);
            createObjectCallback(obj);
#endif
#endif
        }
Exemplo n.º 2
0
        public void CreateInstanceFromConstruct(System.Type type, FairyGUI.UIPackage.CreateObjectCallback createObjectCallback)
        {
            var createInstanceAsyncMethod = type.GetMethod("CreateInstanceAsync", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            createInstanceAsyncMethod.Invoke(null, new object[] {
                (FairyGUI.UIPackage.CreateObjectCallback)createObjectCallback
            });
        }
Exemplo n.º 3
0
        public void CreateInstanceAsync(System.Type type, FairyGUI.UIPackage.CreateObjectCallback createObjectCallback)
        {
#if _CREATE_INSTANCE
            var createInstanceAsyncMethod = type.GetMethod("CreateInstance", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
            createInstanceAsyncMethod.Invoke(null, new object[] {
                createObjectCallback
            });
#else
            Debug.Log("$$ package loaded, CreateInstanceAsync ...");
            var pakAtt      = GetPakIDAttFromType(type);
            var packageName = pakAtt.Name;
            var itemName    = type.Name;
            FairyGUI.UIPackage.CreateObjectAsync(packageName, itemName, createObjectCallback);
#endif
        }