In the example for UnderTransform(Method) in the readme, it says that context.ObjectInstance can be checked and used as a potential parent for a newly created GameObject made from a factory. However, context.ObjectInstance is null when running the given example.
Code I tested with:
public class TestInstaller : MonoInstaller
{
public GameObject fooPrefab;
public override void InstallBindings()
{
Container.BindFactory<Foo, Foo.Factory>()
.FromComponentInNewPrefab(fooPrefab)
.UnderTransform(GetParent);
}
Transform GetParent(InjectContext context)
{
Debug.Log(context.ObjectInstance);
if (context.ObjectInstance is Component)
{
return ((Component)context.ObjectInstance).transform;
}
return null;
}
}
public class Foo : MonoBehaviour
{
public class Factory : PlaceholderFactory<Foo> { }
}
public class FooSpawner : MonoBehaviour
{
[Inject] readonly Foo.Factory fooFactory;
void Start()
{
fooFactory.Create();
}
}
There's also a typo in that section, FromComponentInNewGameObject is not a valid method (perhaps it should've been FromNewComponentOnNewGameObject?)
In the example for UnderTransform(Method) in the readme, it says that context.ObjectInstance can be checked and used as a potential parent for a newly created GameObject made from a factory. However, context.ObjectInstance is null when running the given example.
Code I tested with:
There's also a typo in that section, FromComponentInNewGameObject is not a valid method (perhaps it should've been FromNewComponentOnNewGameObject?)