Fix: use DestroyImmediate when disposing LifetimeScope outside Play Mode - #861
Open
Acharad wants to merge 1 commit into
Open
Fix: use DestroyImmediate when disposing LifetimeScope outside Play Mode#861Acharad wants to merge 1 commit into
Acharad wants to merge 1 commit into
Conversation
|
@Acharad is attempting to deploy a commit to the hadashia's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #814
Hit the same issue @Nitero described in #814 — calling
Dispose()ona
LifetimeScopeoutside Play Mode throws, because it always callsDestroy(), which only works while the game is actually running. Raninto this myself while writing an Editor test, and figured I'd fix it
properly instead of working around it locally.
Dispose()now checksApplication.isPlayingand callsDestroyImmediate(gameObject)when it's false. Play Mode behavior(
Destroy) is unchanged.Didn't add an automated test — this repo's only test assembly
(
VContainer.Tests.asmdef) isn't restricted to the Editor platform,so Unity runs it under PlayMode, where
Application.isPlayingisalways true and this branch would never actually be exercised.
Verified manually instead. Happy to add a proper Editor-only test
assembly in a follow-up if that'd be useful.