Beispiel #1
0
 protected override void ShowView(AView view)
 {
     if (false == _viewList.Contains(view))
     {
         view.onDestroyHandler += RemoveView;
         _viewList.Add(view);
     }
 }
Beispiel #2
0
 /// <summary>
 /// View对象销毁的回调
 /// </summary>
 /// <param name="view"></param>
 void OnViewDestroy(AView view)
 {
     if (Current == view)
     {
         Current.onDestroyHandler -= OnViewDestroy;
         Current = null;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 界面异步创建完成
 /// </summary>
 /// <param name="view"></param>
 private void OnAsyncCreated(AView view)
 {
     _layer.ShowView(view);
     if (null != _onCreated)
     {
         _onCreated.Invoke(view as AViewType, _token);
     }
 }
Beispiel #4
0
 public override void Clear()
 {
     if (null != Current)
     {
         Current.onDestroyHandler -= OnViewDestroy;
         Current.Destroy();
         Current = null;
     }
 }
Beispiel #5
0
        /// <summary>
        /// 创建视图
        /// </summary>
        /// <param name="type"></param>
        /// <param name="prefab"></param>
        /// <param name="parent"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static AView Create(Type type, GameObject prefab, Transform parent, object data = null)
        {
            GameObject go = GameObject.Instantiate(prefab, parent);

            go.name = prefab.name;

            AView view = Activator.CreateInstance(type) as AView;

            view.SetGameObject(go, data);
            return(view);
        }
Beispiel #6
0
        /// <summary>
        /// 切换视图
        /// </summary>
        /// <param name="view"></param>
        protected override void ShowView(AView view)
        {
            if (null != Current)
            {
                Current.onDestroyHandler -= OnViewDestroy;
                Current.Destroy();
                Current = null;
            }

            Current = view;
            view.onDestroyHandler += OnViewDestroy;
        }
Beispiel #7
0
 public void ChangeSiblingIndex(AView view, int index)
 {
     view.gameObject.transform.SetSiblingIndex(index);
 }
Beispiel #8
0
 void RemoveView(AView view)
 {
     view.onDestroyHandler -= RemoveView;
     _viewList.Remove(view);
 }
Beispiel #9
0
 /// <summary>
 /// 显示视图
 /// </summary>
 /// <param name="view"></param>
 protected abstract void ShowView(AView view);
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="prefab"></param>
        /// <param name="parent"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static T Create <T>(GameObject prefab, Transform parent, object data = null) where T : AView
        {
            AView view = Create(typeof(T), prefab, parent, data);

            return(view as T);
        }