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); }
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); }
public static IView AddChildView <TModel>(this Transform transform, GameObject prefab, TModel model) where TModel : IModel { return(transform.AddChildView <IView, TModel>(prefab, model)); }
public static IView AddChildView(this Transform transform, GameObject prefab) { return(transform.AddChildView <IView>(prefab)); }
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)); }
public static TView AddChildView <TView>(this Transform transform, TView prefab) where TView : Component, IView { return(transform.AddChildView <TView>(prefab.gameObject)); }
public static IView AddChildView <TModel>(this Transform transform, Component prefab, TModel model) where TModel : IModel { return(transform.AddChildView(prefab.gameObject, model)); }
public static IView AddChildView(this Transform transform, Component prefab) { return(transform.AddChildView(prefab.gameObject)); }