-
Notifications
You must be signed in to change notification settings - Fork 447
fix: networkvariablebase not being reinitialized if networkobject persists between sessions #3181
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
Merged
NoelStephensUnity
merged 12 commits into
develop-2.0.0
from
fix/networkvariablebase-not-being-reinitialized-if-networkobject-persists-between-sessions
Feb 3, 2025
Merged
Conversation
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
…einitialized-if-networkobject-persists-between-sessions
Changing the approach to this fix while also cleaning up the initialize process so it can be invoked when the derived class is not yet fully spawned (or just recently instantiated) without potentially assigning the wrong NetworkManager instance. It is being invoked multiple times anyway, so this just gradually initializes all of the required elements until it is finally considered "initialized". This also prevents OnInitialize from being invoked multiple times during this process and OnInitialize is only invoked as a last step to being considered "initialized". Added a Deinitialize step to NetworkVariableBase when despawning a NetworkObject where the initialized status is reset. This allows for the next spawning of the NetworkObject (if in-scene placed or pooled) to run through the initialization process.
This validates the fix for resetting the NetworkVariableBase.LastUpdated property when a NetworkObject is persisted (i.e. recycled via in-scene placed NetworkObject or object pools). Also minor update to prevent the integration test from logging a blank entry if there has been no logs added.
EmandM
approved these changes
Jan 24, 2025
NoelStephensUnity
added a commit
that referenced
this pull request
Jan 24, 2025
…einitialized-if-networkobject-persists-between-sessions
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.
This PR resolves the issue where a
NetworkObject
instance with aNetworkBehaviour
that includes one or moreNetworkVariableBase
derived class properties persists between network sessions is not having itsNetworkVariableBase.Initialize
method invoked again when spawned again. This resulted in clients not being updated to changes in theNetworkVariableBase
derived class properties for a period of time equal to the duration of the last spawned time frame from its previous network session.MTTB-881
Changelog
NetworkVariableBase
derived classes were not being re-initialized if the associatedNetworkObject
instance was not destroyed and respawned.Testing and Documentation
NetworkVariableBaseInitializesWhenPersisted
.