You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I try to create a pool that gets param and value because I need this param in my custom factory for the correct initializing of instantiated objects.
The version without the param works as expected - (I mean MemoryPool, and related to it factories)
Unfortunately, the version with param cause to the exception that not clear to me why it's trying to resolve IFactory instead of the requested one - IFactory<IAtata, IKokoko>
When :
Container.Instantiate<MemoryPool<IAtata, IKokoko>>(new object[] { settings, factory });
the line is running, I get an error :
ZenjectException: Unable to resolve 'IFactory' while building object with type 'MemoryPool<IAtata, IKokoko>'. Object graph: MemoryPool<IAtata, IKokoko>
To Reproduce
Run an attached code in editor.
Expected behavior
That it will inject all as expected.
Screenshots
Extenject and Unity info (please complete the following information):
public interface IAtata
{
string Name { get; set; }
}
public interface IKokoko
{
string Name { get; set; }
}
public class Kokoko : IKokoko
{
public string Name { get; set; }
public class Factory : PlaceholderFactory<IAtata, IKokoko>
{
}
}
public class KokokoFactory : IFactory<IAtata, IKokoko>
{
public IKokoko Create(IAtata atata)
{
IKokoko kokoko = new Kokoko();
kokoko.Name = atata.Name;
return kokoko;
}
}
public class Installer : MonoInstaller<Installer>
{
public override void InstallBindings()
{
var settings = new MemoryPoolSettings()
{
InitialSize = 100,
ExpandMethod = PoolExpandMethods.Double,
};
Container.BindFactory<IAtata, IKokoko, Kokoko.Factory>().FromFactory<KokokoFactory>().NonLazy();
var factory = Container.Resolve<Kokoko.Factory>();
// ZenjectException: Unable to resolve 'IFactory<IKokoko>' while building object with type 'MemoryPool<IAtata, IKokoko>'. Object graph: MemoryPool<IAtata, IKokoko>
var pool = Container.Instantiate<MemoryPool<IAtata, IKokoko>>(new object[] { settings, factory });
}
}
The text was updated successfully, but these errors were encountered:
In order to instantiate the pool correctly you should more likelly create a factory of pools, so you prepare that factory with the needed settings for the pool to be created as you like
also you wouldnt need to resolve in the install phase
your code should look like this with these changes
Also as an extra note, technically you should never resolve in the install phase as some injects are queued, and the install phase may have not finished yet on other installers
Describe the bug
I try to create a pool that gets param and value because I need this param in my custom factory for the correct initializing of instantiated objects.
The version without the param works as expected - (I mean MemoryPool, and related to it factories)
Unfortunately, the version with param cause to the exception that not clear to me why it's trying to resolve IFactory instead of the requested one - IFactory<IAtata, IKokoko>
When :
Container.Instantiate<MemoryPool<IAtata, IKokoko>>(new object[] { settings, factory });
the line is running, I get an error :
ZenjectException: Unable to resolve 'IFactory' while building object with type 'MemoryPool<IAtata, IKokoko>'. Object graph: MemoryPool<IAtata, IKokoko>
To Reproduce
Run an attached code in editor.
Expected behavior
That it will inject all as expected.
Screenshots
Extenject and Unity info (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: