示例#1
0
文件: AView.cs 项目: nirvana2/Zero
        /// <summary>
        /// 通过Prefab创建AView对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="prefab">Prefab对象</param>
        /// <param name="parentView">作为父对象的AView</param>
        /// <param name="parentTransform">父Transform容器</param>
        /// <param name="data">携带的参数</param>
        /// <returns></returns>
        public static T Create <T>(GameObject prefab, AView parentView, Transform parentTransform, object data = null) where T : AView
        {
            AView view = AViewMgr.CreateViewFromPrefab(prefab, parentTransform, prefab.name, typeof(T));

            parentView.AddChild(view);
            if (data != null)
            {
                view.SetData(data);
            }
            return(view as T);
        }
示例#2
0
文件: AView.cs 项目: nirvana2/Zero
        /// <summary>
        /// 销毁对象
        /// </summary>
        public void Destroy()
        {
            if (IsDestroyed)
            {
                return;
            }

            WhenDisable();
            RemoveFromParent();
            AViewMgr.DestroyView(this);
            gameObject = null;
            WhenDestroy();
        }