-
Notifications
You must be signed in to change notification settings - Fork 459
fix: Attachables destroy order of operations #3931
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
base: develop-2.0.0
Are you sure you want to change the base?
Changes from all commits
2dd2918
21ff894
842b67b
84a5dd9
ce4f577
ffca0f3
e2e0eee
6daf3ea
a73b597
9e4f0e5
ffece95
aec2ae6
42e3d83
eace6b8
3280374
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1688,8 +1688,52 @@ public static void NetworkHide(List<NetworkObject> networkObjects, ulong clientI | |
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns true if the NetworkObject is in the middle of being destroyed. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This is particularly useful when determining if something is being de-spawned | ||
| /// normally or if it is being de-spawned because the NetworkObject/GameObject is | ||
| /// being destroyed. | ||
| /// </remarks> | ||
| internal bool IsDestroying { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Applies the despawning flag for the local instance and | ||
| /// its child NetworkBehaviours. Private to assure this is | ||
| /// only invoked from within OnDestroy. | ||
| /// </summary> | ||
| internal void SetIsDestroying() | ||
| { | ||
| if (IsDestroying) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (m_ChildNetworkBehaviours != null) | ||
| { | ||
| foreach (var childBehaviour in m_ChildNetworkBehaviours) | ||
| { | ||
| // Just ignore and continue processing through the entries | ||
| if (!childBehaviour) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| // Keeping the property a private set to assure this is | ||
| // the only way it can be set as it should never be reset | ||
| // back to false once invoked. | ||
| childBehaviour.SetIsDestroying(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, are we sure that all the child behaviours will be destroyed if the parent NetworkObject is destroyed? I know most of the time that'll be true, but what happens if just the gameObject the NetworkObject is on is destroyed, and a child gameObject isn't?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is actually part of the issue this PR resolves for... the question you just asked can be answered by checking Whether it is a |
||
| } | ||
| } | ||
| IsDestroying = true; | ||
| } | ||
|
|
||
| private void OnDestroy() | ||
| { | ||
| // Apply the is destroying flag | ||
| SetIsDestroying(); | ||
|
|
||
| var networkManager = NetworkManager; | ||
| // If no NetworkManager is assigned, then just exit early | ||
| if (!networkManager) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.