Exemple #1
0
        /// <summary>
        /// 初始化界面。
        /// </summary>
        /// <param name="uiFormAssetName">界面资源名称。</param>
        /// <param name="uiGroup">界面所处的界面组。</param>
        /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
        /// <param name="isNewInstance">是否是新实例。</param>
        /// <param name="userData">用户自定义数据。</param>
        public virtual void OnInit(string uiFormAssetName, IUIGroup uiGroup, bool pauseCoveredUIForm, bool isNewInstance, object userData)
        {
            this.m_UIFormAssetName = uiFormAssetName;

            if (isNewInstance)
            {
                this.m_UIGroup = uiGroup;
            }
            else if (this.m_UIGroup != uiGroup)
            {
                LTLog.Error("UI group is inconsistent for new-instance UI form.");
                return;
            }

            m_DepthInUIGroup     = uiGroup.Depth;
            m_PauseCoveredUIForm = pauseCoveredUIForm;

            if (!isNewInstance)
            {
                return;
            }

            RectTransform transform = GetComponent <RectTransform>();

            transform.anchorMin        = Vector2.zero;
            transform.anchorMax        = Vector2.one;
            transform.anchoredPosition = Vector2.zero;
            transform.sizeDelta        = Vector2.zero;
        }
        /// <inheritdoc />
        public IUIForm CreateUIForm(object uiFormInstance, IUIGroup uiGroup, object userData)
        {
            GameObject gameObject = uiFormInstance as GameObject;

            if (gameObject == null)
            {
                LTLog.Error("UI form instance is invalid.");
                return(null);
            }

            Transform transform = gameObject.transform;

            transform.SetParent(((MonoBehaviour)uiGroup.Helper).transform);
            transform.localScale = Vector3.one;

            return(gameObject.GetComponent <IUIForm>());
        }