It is used to instantiate objects derived from MonoBehaviour. When inheriting this class, the objects and parameters to be created must be defined as types.
Sample uses:
public class Installer : GameObjectInstaller
{
public override void Install(DIContainer container)
{
container.BindFactory<FooItem.Factory>();
}
}
public class SampleClass : MonoInjecter
{
[Inject]
private readonly FooItem.Factory _fooItemFactory;
[SerializeField]
private FooItem _fooItemPrefab;
protected override void Awake()
{
base.Awake();
FooItem fooItem = _fooItemFactory.Create(_fooItemPrefab, "Sample string");
}
}
public class FooItem : MonoBehaviour, IFactorable<string>
{
[Inject]
private readonly Foo _foo;
public void InitializeFactory(string variable)
{
Debug.Log($"{_foo.index}: String variable is: {variable}");
}
public class Factory : SeparatedGameObjectFactory<FooItem, string> { }
}