Closed enpiech closed 1 year ago
Then Dispose method of AComponent is invoked - which is not expected.
If AComponent
's Lifetime is a .Singleton
, it should not have this behavior. (Or it's a bug.)
If AComponent
's Lifetime is .Scoped
, then BScope
also creates and retains an instance of AComponent
. (This is the main difference between Singleton and Scoped.)
It is probably this pattern that your AComponent is Dispose.
Thanks for your response.
Because I use RegisterComponentInHierarchy, AComponent
's Lifetime is .Scoped
.
I have a parent LifetimeScope (AScope), that Register a component AComponent (which implement IDisposable) on scene. then resolve it in RegisterBuildCallback. After that. I create a child scope (BScope) via script AScope.CreateChild. Some class in BScope need AComponent. Then I dispose BScope. Then Dispose method of AComponent is invoked - which is not expected. Is there any way to not invoke AComponent Dispose when dispose BScope? Cause I still need AComponent alive Thanks