Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveNonAutomaticallyInitializedCollections executes too late #160

Open
lgarczyn opened this issue Nov 19, 2024 · 1 comment
Open

RemoveNonAutomaticallyInitializedCollections executes too late #160

lgarczyn opened this issue Nov 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@lgarczyn
Copy link

lgarczyn commented Nov 19, 2024

Setup:

  • create a new collection A
  • set A.AutomaticallyLoaded to false
  • create empty scene
  • add a script that calls CollectionsRegistry.Instance.RegisterCollection(A); on Awake
  • Enter playmode

Expected results:

  • collection is registered properly

Actual results:

  • Awake is called, but A is still in CollectionsRegistry.collections
  • RemoveNonAutomaticallyInitializedCollections is then called, removing A
  • A is not loaded

Workarounds:

  • wait one frame to load collections

Possible solutions:

  • do not use the same collections list for editor and playmode
  • use PlayModeStateChange.ExitingEditMode instead of PlayModeStateChange.EnteredEditMode
@brunomikoski brunomikoski added the bug Something isn't working label Nov 19, 2024
@lgarczyn
Copy link
Author

lgarczyn commented Nov 19, 2024

Another issue with modifying collections on enter playmode:

The modifications are serialized, leading to git changes during playmode

The order is not restored properly at the end, leading to semi-random changes to the order of collections every time we leave playmode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants