AnnulusGames/MagicTween

ArchetypeStore is Disposed when new World is destoryed.

threeplus opened this issue · 1 comments

In MagicTweenInitializationSystem, ArchetypeStore.Initialize() and ArchetypeStore.Dispose(), is calling when any World is created and disposed.

It cause the NativeArry coreComponentTypes disposed, after any World disposed. This will cause the following error when using MagicTween later:
ObjectDisposedException: The Unity.Collections.NativeArray`1[Unity.Entities.ComponentType] has been deallocated, it is not allowed to access it

Suggestion:

  1. Add a checking for the World created and disposed.
  2. Don't use static for coreComponentTypes, created it in every World.
  3. Make Initialize() and Dispose() public to users.

BTW, good job for the library. I like it very much.

From v0.1.2, a World check was added to the initialization process of MagicTweenInitializationSystem to prevent it from being called multiple times.
(This works, but may not be a very good solution. I'm still working on the design when using multiple worlds.)