Skip to content

Commit d09a7c9

Browse files
style
updating comment in area updated for further clarity on the requirements to resetting the dirty and last sent time after the associated NetworkObject has been spawned.
1 parent 511af60 commit d09a7c9

File tree

1 file changed

+11
-6
lines changed
  • com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections

1 file changed

+11
-6
lines changed

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,17 @@ public NetworkList(IEnumerable<T> values = default,
6060

6161
internal override void OnSpawned()
6262
{
63-
// If we are dirty and have write permissions by the time the NetworkObject
64-
// is finished spawning (same frame) and the instance is on the spawn authority
65-
// side, then go ahead and reset the dirty related properties for NetworkList
66-
// in the event user script has made changes when spawning to prevent duplicate
67-
// entries (i.e. they are sent via CreateObjectMessage so we don't need to send
68-
// the NetworkVariableDeltaMessage.
63+
// If the NetworkList is:
64+
// - Dirty
65+
// - State updates can be sent:
66+
// -- The instance has write permissions.
67+
// -- The last sent time plus the max send time period is less than the current time.
68+
// - User script has modified the list during spawn.
69+
// - This instance is on the spawn authority side.
70+
// Then by the time the NetworkObject is finished spawning (on the same frame), then go
71+
// ahead and reset the dirty related properties and last sent time to prevent duplicate
72+
// entries from being sent (i.e. CreateObjectMessage will contain the changes so we
73+
// don't need to send a proceeding NetworkVariableDeltaMessage).
6974
if (IsDirty() && CanSend() && m_NetworkBehaviour.HasAuthority)
7075
{
7176
UpdateLastSentTime();

0 commit comments

Comments
 (0)