negitamago
2/23/2019 - 1:53 PM

FromComponentOn()は引数のGameObjectに予めアタッチされたコンポーネントを使う http://negi-lab.blog.jp/ZenjectInstaller

FromComponentOn()は引数のGameObjectに予めアタッチされたコンポーネントを使う http://negi-lab.blog.jp/ZenjectInstaller

using UnityEngine;
using Zenject;

// FromComponentOn()は引数のGameObjectに予めアタッチされたコンポーネントを使う
public class PronamaInputInstaller : MonoInstaller
{
    [SerializeField] GameObject pronamaGameObject;

    public override void InstallBindings ()
    {
        Container
            .BindInterfacesAndSelfTo<PronamaInput> ()
            .FromComponentOn ( pronamaGameObject )
            .AsSingle ();
    }
}