Exemplo n.º 1
0
 /// <summary>
 /// View对象销毁的回调
 /// </summary>
 /// <param name="view"></param>
 void OnViewDestroy(AView view)
 {
     view.onDestroyHandler -= OnViewDestroy;
     if (Current == view)
     {
         Current = null;
     }
 }
Exemplo n.º 2
0
 public override void ShowView(AView view)
 {
     if (false == _viewList.Contains(view))
     {
         view.onDestroyHandler += RemoveView;
         _viewList.Add(view);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 4
0
 public override void Clear()
 {
     if (null != Current)
     {
         Current.onDestroyHandler -= OnViewDestroy;
         Current.Destroy();
         Current = null;
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 切换视图
        /// </summary>
        /// <param name="view"></param>
        public override void ShowView(AView view)
        {
            if (null != Current)
            {
                Current.onDestroyHandler -= OnViewDestroy;
                //检查是否存在切换效果,没有则直接销毁老的界面
                if (null == _switchAnimatorType)
                {
                    Current.Destroy();
                    Current = null;
                }
                else
                {
                    var animator = (ASingularViewSwitchAnimator)Activator.CreateInstance(_switchAnimatorType);
                    animator.Old = Current;
                    animator.StartSwitch(Current, view, OnSwitchComplete);
                }
            }

            Current = view;
            view.onDestroyHandler += OnViewDestroy;
        }
Exemplo n.º 8
0
 public void ChangeSiblingIndex(AView view, int index)
 {
     view.gameObject.transform.SetSiblingIndex(index);
 }
Exemplo n.º 9
0
 void RemoveView(AView view)
 {
     view.onDestroyHandler -= RemoveView;
     _viewList.Remove(view);
 }
Exemplo n.º 10
0
 /// <summary>
 /// 显示视图
 /// </summary>
 /// <param name="view"></param>
 public abstract void ShowView(AView view);
Exemplo n.º 11
0
 /// <summary>
 /// 显示视图
 /// </summary>
 /// <param name="view"></param>
 protected abstract void ShowView(AView view);
Exemplo n.º 12
0
 /// <summary>
 /// 开始切换动画
 /// </summary>
 /// <param name="oldView">旧视图</param>
 /// <param name="newView">新视图</param>
 /// <param name="onSwitchComplete">切换完成后必须调用该方法,才可以正确销毁旧的视图</param>
 public abstract void StartSwitch(AView oldView, AView newView, Action <ASingularViewSwitchAnimator> onSwitchComplete);
Exemplo n.º 13
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);
        }