> For the complete documentation index, see [llms.txt](https://tariksavas.gitbook.io/tarject/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tariksavas.gitbook.io/tarject/docs/how-to-use/factory/separatedgameobjectfactory.md).

# SeparatedGameObjectFactory

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:

```csharp
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>  { }
}
```
