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
I was hoping to create a factory to create a Npc class that responds to IStartable, ITickable. But by registering Npc as Lifetime.Transient and AsImplementedInterfaces() it will create 2 Npc instances immediately. It seems VContainer resolves all classes that implement IStartable, ITickable on startup to collect C# classes that need updating. I wonder if there is a way to resolve/create Npc class instances later but being able to get called by IStartable.Start and ITickable.Tick? Or it has to be the other way around i.e. MonoNpc owning and updating Npc instead of Npc owning MonoNpc and updated by VContainer?
And I would also like to ask is it possible to make LifetimeScope.Configure() async? It seems not working if I mark it async and use await _npcPrefab.LoadAssetAsync<GameObject>(); in it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I have following classes:
And I register in the
LifeTimeScope
likeI was hoping to create a factory to create a
Npc
class that responds toIStartable
,ITickable
. But by registeringNpc
asLifetime.Transient
andAsImplementedInterfaces()
it will create 2Npc
instances immediately. It seems VContainer resolves all classes that implementIStartable
,ITickable
on startup to collect C# classes that need updating. I wonder if there is a way to resolve/createNpc
class instances later but being able to get called byIStartable.Start
andITickable.Tick
? Or it has to be the other way around i.e.MonoNpc
owning and updatingNpc
instead ofNpc
owningMonoNpc
and updated by VContainer?And I would also like to ask is it possible to make
LifetimeScope.Configure()
async? It seems not working if I mark it async and useawait _npcPrefab.LoadAssetAsync<GameObject>();
in it.Thank you.
Beta Was this translation helpful? Give feedback.
All reactions