Esempio n. 1
0
        public static UIFormObject Create(string name, object uiFormInstance, object uiFormAsset)
        {
            if (uiFormAsset == null)
            {
                throw new LufyException("UI form asset is invalid.");
            }

            UIFormObject uiInstanceObject = ReferencePool.Acquire <UIFormObject>();

            uiInstanceObject.Initialize(name, uiFormInstance);
            uiInstanceObject.m_UIFormAsset = uiFormAsset;
            return(uiInstanceObject);
        }
Esempio n. 2
0
        void LoadAssetSuccess(string assetName, object asset, float duration, object userData)
        {
            GameObject obj = GameObject.Instantiate(asset as GameObject);

            obj.name = obj.name.Substring(0, obj.name.Length - 7);
            obj.transform.SetParent(m_InstanceRoot);
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            UIFormLogic uiFormInstanceObject = obj.GetComponent <UIFormLogic>();

            m_cachedForms.Add(assetName, uiFormInstanceObject);
            m_InstancePool.Register(UIFormObject.Create(assetName, uiFormInstanceObject, asset), true);

            uiFormInstanceObject.OnInit(userData);

            InternalOpenUIForm(assetName, uiFormInstanceObject, duration, userData);
        }
Esempio n. 3
0
        /// <summary>
        /// 打开界面。
        /// </summary>
        /// <param name="uiFormAssetName">界面资源名称。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>界面的序列编号。</returns>
        public void OpenUIForm(string uiFormAssetName, object userData)
        {
            if (string.IsNullOrEmpty(uiFormAssetName))
            {
                throw new LufyException("UI form asset name is invalid.");
            }

            if (m_ResManager == null)
            {
                throw new LufyException("ResManager is invalid.");
            }

            if (m_PoolManager == null)
            {
                throw new LufyException("ObjectPoolManager is invalid.");
            }

            UIFormLogic uiFormInstanceObject = null;

            m_cachedForms.TryGetValue(uiFormAssetName, out uiFormInstanceObject);
            if (uiFormInstanceObject == null)
            {
                UIFormObject obj = m_InstancePool.Spawn(uiFormAssetName);
                uiFormInstanceObject = obj?.Target as UIFormLogic;
                if (uiFormInstanceObject == null)
                {
                    m_ResManager.LoadAsset(uiFormAssetName, m_LoadAssetCallbacks, userData);
                }
                else
                {
                    m_cachedForms.Add(uiFormAssetName, uiFormInstanceObject);

                    InternalOpenUIForm(uiFormAssetName, uiFormInstanceObject, 0, userData);
                }
            }
            else
            {
                m_formList.Remove(uiFormInstanceObject);

                InternalOpenUIForm(uiFormAssetName, uiFormInstanceObject, 0, userData);
            }
        }