예제 #1
0
파일: View.cs 프로젝트: c-c-c-c/cafu_core
        public static TView AddChildView <TView, TModel>(this Transform transform, GameObject prefab, TModel model)
            where TView : IView
            where TModel : IModel
        {
            var childView          = transform.AddChildView <TView>(prefab);
            var childMonoBehaviour = childView as MonoBehaviour;

            if (childMonoBehaviour == default(MonoBehaviour))
            {
                throw new InvalidOperationException($"'{typeof(TView).FullName}' is not inheritance MonoBehaviour.");
            }

            (childView as IInjectableView <TModel>)?.Inject(model);

            return(childView);
        }
예제 #2
0
        public static TView AddChildView <TView, TModel>(this Transform transform, GameObject prefab, TModel model)
            where TView : IView
            where TModel : IModel
        {
            TView childView = transform.AddChildView <TView>(prefab);
            // ReSharper disable once SuspiciousTypeConversion.Global
            MonoBehaviour childMonoBehaviour = childView as MonoBehaviour;

            if (childMonoBehaviour == default(MonoBehaviour))
            {
                throw new InvalidOperationException(string.Format("'{0}' is not inheritance MonoBehaviour.", typeof(TView).FullName));
            }
            if (childView is IInjectableView <TModel> )
            {
                ((IInjectableView <TModel>)childView).Inject(model);
            }

            #region v2.0.0 で消す
#pragma warning disable 618

            // Model 不要の IViewBuilder.Build() をコール
            childMonoBehaviour.gameObject.GetComponents <IViewBuilder>().ToList().ForEach(
                (x) => {
                x.Build();
            }
                );
            if (model != null)
            {
                // Model を要する IViewBuilder<TModel>.Build(TModel model) をコール
                childMonoBehaviour.gameObject.GetComponents <IViewBuilder <TModel> >().ToList().ForEach(
                    (x) => {
                    x.Build(model);
                }
                    );
            }

#pragma warning restore 618
            #endregion

            return(childView);
        }
예제 #3
0
 public static IView AddChildView <TModel>(this Transform transform, GameObject prefab, TModel model)
     where TModel : IModel
 {
     return(transform.AddChildView <IView, TModel>(prefab, model));
 }
예제 #4
0
 public static IView AddChildView(this Transform transform, GameObject prefab)
 {
     return(transform.AddChildView <IView>(prefab));
 }
예제 #5
0
파일: View.cs 프로젝트: c-c-c-c/cafu_core
 public static TView AddChildView <TView, TModel>(this Transform transform, TView prefab, TModel model)
     where TView : Component, IView
     where TModel : IModel
 {
     return(transform.AddChildView <TView, TModel>(prefab.gameObject, model));
 }
예제 #6
0
파일: View.cs 프로젝트: c-c-c-c/cafu_core
 public static TView AddChildView <TView>(this Transform transform, TView prefab)
     where TView : Component, IView
 {
     return(transform.AddChildView <TView>(prefab.gameObject));
 }
예제 #7
0
파일: View.cs 프로젝트: c-c-c-c/cafu_core
 public static IView AddChildView <TModel>(this Transform transform, Component prefab, TModel model)
     where TModel : IModel
 {
     return(transform.AddChildView(prefab.gameObject, model));
 }
예제 #8
0
파일: View.cs 프로젝트: c-c-c-c/cafu_core
 public static IView AddChildView(this Transform transform, Component prefab)
 {
     return(transform.AddChildView(prefab.gameObject));
 }