Exemplo n.º 1
0
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public static IView AddChildView <TModel>(this Transform transform, GameObject prefab, TModel model)
     where TModel : IModel
 {
     return(transform.AddChildView <IView, TModel>(prefab, model));
 }
Exemplo n.º 4
0
 public static IView AddChildView(this Transform transform, GameObject prefab)
 {
     return(transform.AddChildView <IView>(prefab));
 }
Exemplo n.º 5
0
 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));
 }
Exemplo n.º 6
0
 public static TView AddChildView <TView>(this Transform transform, TView prefab)
     where TView : Component, IView
 {
     return(transform.AddChildView <TView>(prefab.gameObject));
 }
Exemplo n.º 7
0
 public static IView AddChildView <TModel>(this Transform transform, Component prefab, TModel model)
     where TModel : IModel
 {
     return(transform.AddChildView(prefab.gameObject, model));
 }
Exemplo n.º 8
0
 public static IView AddChildView(this Transform transform, Component prefab)
 {
     return(transform.AddChildView(prefab.gameObject));
 }