Skip to content

Commit ba35384

Browse files
chore: merge release 2.2.0 back into develop-2.0.0 (#3179)
* update updating package * update updating changelog * update moving minimum editor back down to 6000.0 * fix Fixing the changelog version goof of mine. Making the license copyright just a year and not year range. * style removing whitespace from copyright notice. adding dash to changelog header * style Removing whitespaces for PVP-124-2 issues. * style missed one whitespace... * chore: merge develop 2 0 0 updates with SessionOwner permissions (#3176) * fix: clamp spawntimeout to recommended range (#3174) * update Clamping spawntimeout * update improving parenting failed message when either the child or parent NetworkObject is not spawnd. * update Update the local SceneEventData.SceneEventType on the authority side for SceneLoadComplete. * style removing whitespaces * feat: Add a SessionOwner ObjectStatus and allow InScenePlaced network objects to be distributed (#3175) * Initial pass on SessionOwner ownership flag * feat: Add SessionOwner OwnershipStatus flag * update removing additional session owner accessor. * Add OwnershipPermissions tests * fix client connect * Revert "fix client connect" This reverts commit 3c3b354. * update object distribution for in-scene placed NetworkObjects needs to use the InScenePlacedSourceGlobalObjectIdHash when building an object distribution list. * Add changelog * Remove unnecessary change * Remove Settings.json * Reword CHANGELOG * fix DAHost should not distribute session owner permission NetworkObjects. When client is promoted to session owner, for now newly promoted client takes ownership of NetworkObjects that have the SessionOwner permission set. Only prevent non-session owners from taking ownership of a NetworkObject with the SessionOwner permission set. * test fix Avoid the RemoveOwnership client-server only method. * style Visual studio code cleanup likes to sort by alpha... fixing for our standards. * update Adding check for session owner trying to change ownership to a non-session owner client. * test Adding an additional validation that a non-session owner cannot change ownership and that a session owner cannot change ownership to a non-session owner when the NetworkObject in question has the SessionOwner permissions set. --------- Co-authored-by: NoelStephensUnity <[email protected]> --------- Co-authored-by: Emma <[email protected]> * fix NetworkAnimator started throwing this exception: "Objects are trying to be loaded during a domain backup. This is not allowed as it will lead to undefined behaviour!" When MPPM was being used. This has to do with the OnBeforeSerialize method and potentially an order of operations issue. We can accomplish the same serialization within OnValidate, but went ahead and made it virtual in order to provide users with the ability to override and handle their own validation. * fix: server, host, or session owner not populating in-scene placed object table when started (#3177) * fix This fixes the issue with the server, host, or session owner not adding in-scene placed NetworkObjects to its internal table if the scene was loaded prior to starting the NetworkManager. * update Adding change log entry * update Adding PR# to this entry. * style remove whitespace * update adding unreleased change log --------- Co-authored-by: Emma <[email protected]>
1 parent 628868a commit ba35384

22 files changed

+169
-139
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).
88

9-
[Unreleased]
9+
## [Unreleased]
10+
11+
### Added
12+
13+
### Fixed
14+
15+
### Changed
16+
17+
18+
## [2.2.0] - 2024-12-12
1019

1120
### Added
1221

@@ -16,6 +25,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1625

1726
### Fixed
1827

28+
- Fixed issue where the server, host, or session owner would not populate the in-scene place `NetworkObject` table if the scene was loaded prior to starting the `NetworkManager`. (#3177)
1929
- Fixed issue where the `NetworkObjectIdHash` value could be incorrect when entering play mode while still in prefab edit mode with pending changes and using MPPM. (#3162)
2030
- Fixed issue where a sever only `NetworkManager` instance would spawn the actual `NetworkPrefab`'s `GameObject` as opposed to creating an instance of it. (#3160)
2131
- Fixed issue where only the session owner (as opposed to all clients) would handle spawning prefab overrides properly when using a distributed authority network topology. (#3160)
@@ -216,8 +226,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
216226
## [2.0.0-exp.2] - 2024-04-02
217227

218228
### Added
219-
- Added updates to all internal messages to account for a distributed authority network session connection. (#2863)
220-
- Added `NetworkRigidbodyBase` that provides users with a more customizable network rigidbody, handles both `Rigidbody` and `Rigidbody2D`, and provides an option to make `NetworkTransform` use the rigid body for motion. (#2863)
229+
- Added updates to all internal messages to account for a distributed authority network session connection. (#2863)
230+
- Added `NetworkRigidbodyBase` that provides users with a more customizable network rigidbody, handles both `Rigidbody` and `Rigidbody2D`, and provides an option to make `NetworkTransform` use the rigid body for motion. (#2863)
221231
- For a customized `NetworkRigidbodyBase` class:
222232
- `NetworkRigidbodyBase.AutoUpdateKinematicState` provides control on whether the kinematic setting will be automatically set or not when ownership changes.
223233
- `NetworkRigidbodyBase.AutoSetKinematicOnDespawn` provides control on whether isKinematic will automatically be set to true when the associated `NetworkObject` is despawned.
@@ -353,6 +363,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
353363
- Fixed issue where you could not have multiple source network prefab overrides targeting the same network prefab as their override. (#2710)
354364

355365
### Changed
366+
356367
- Changed the server or host shutdown so it will now perform a "soft shutdown" when `NetworkManager.Shutdown` is invoked. This will send a disconnect notification to all connected clients and the server-host will wait for all connected clients to disconnect or timeout after a 5 second period before completing the shutdown process. (#2789)
357368
- Changed `OnClientDisconnectedCallback` will now return the assigned client identifier on the local client side if the client was approved and assigned one prior to being disconnected. (#2789)
358369
- Changed `NetworkTransform.SetState` (and related methods) now are cumulative during a fractional tick period and sent on the next pending tick. (#2777)
@@ -365,6 +376,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
365376
- Changed in-scene placed `NetworkObject`s now set their `IsSceneObject` value when generating their `GlobalObjectIdHash` value. (#2710)
366377
- Changed the default `NetworkConfig.SpawnTimeout` value from 1.0s to 10.0s. (#2710)
367378

379+
368380
## [1.7.1] - 2023-11-15
369381

370382
### Added
@@ -414,7 +426,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
414426
### Added
415427

416428
- Added a protected virtual method `NetworkTransform.OnInitialize(ref NetworkTransformState replicatedState)` that just returns the replicated state reference.
417-
429+
418430
### Fixed
419431

420432
- Fixed issue where invoking `NetworkManager.Shutdown` within `NetworkManager.OnClientStopped` or `NetworkManager.OnServerStopped` would force `NetworkManager.ShutdownInProgress` to remain true after completing the shutdown process. (#2661)

com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private void DisplayNetworkManagerProperties()
237237
if (m_NetworkManager.NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority)
238238
{
239239
EditorGUILayout.PropertyField(m_AutoSpawnPlayerPrefabClientSide, new GUIContent("Auto Spawn Player Prefab"));
240-
}
240+
}
241241
#endif
242242
EditorGUILayout.PropertyField(m_PlayerPrefabProperty, new GUIContent("Default Player Prefab"));
243243

com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
198198
// The below can cause visual anomalies and/or throws an exception within the EditorGUI itself (index out of bounds of the array). and has
199199
// The visual anomaly is when you select one field it is set in the drop down but then the flags selection in the popup menu selects more items
200200
// even though if you exit the popup menu the flag setting is correct.
201-
//var ownership = (NetworkObject.OwnershipStatus)EditorGUI.EnumFlagsField(position, label, (NetworkObject.OwnershipStatus)property.enumValueFlag);
202-
//property.enumValueFlag = (int)ownership;
201+
// var ownership = (NetworkObject.OwnershipStatus)EditorGUI.EnumFlagsField(position, label, (NetworkObject.OwnershipStatus)property.enumValueFlag);
202+
// property.enumValueFlag = (int)ownership;
203203
EditorGUI.EndDisabledGroup();
204204
EditorGUI.EndProperty();
205205
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Unity Companion License (UCL License)
22

3-
com.unity.netcode.gameobjects copyright © 2021-2024 Unity Technologies
3+
com.unity.netcode.gameobjects copyright © 2024 Unity Technologies
44
Licensed under the Unity Companion License for Unity-dependent projects (see https://unity3d.com/legal/licenses/unity_companion_license).
55
Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.
6-
7-

com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,11 @@ private void ParseStateMachineStates(int layerIndex, ref AnimatorController anim
298298
}
299299
}
300300

301-
#endif
302-
303301
/// <summary>
304302
/// Creates the TransitionStateInfoList table
305303
/// </summary>
306304
private void BuildTransitionStateInfoList()
307305
{
308-
#if UNITY_EDITOR
309306
if (m_Animator == null)
310307
{
311308
return;
@@ -323,17 +320,26 @@ private void BuildTransitionStateInfoList()
323320
var stateMachine = animatorController.layers[x].stateMachine;
324321
ParseStateMachineStates(x, ref animatorController, ref stateMachine);
325322
}
326-
#endif
327323
}
328324

325+
/// <summary>
326+
/// In-Editor Only
327+
/// Virtual OnValidate method for custom derived NetworkAnimator classes.
328+
/// </summary>
329+
protected virtual void OnValidate()
330+
{
331+
BuildTransitionStateInfoList();
332+
}
333+
#endif
334+
329335
public void OnAfterDeserialize()
330336
{
331337
BuildDestinationToTransitionInfoTable();
332338
}
333339

334340
public void OnBeforeSerialize()
335341
{
336-
BuildTransitionStateInfoList();
342+
// Do nothing when serializing (handled during OnValidate)
337343
}
338344

339345
internal struct AnimationState : INetworkSerializable
@@ -416,8 +422,8 @@ internal struct AnimationMessage : INetworkSerializable
416422
internal bool HasBeenProcessed;
417423

418424
// This is preallocated/populated in OnNetworkSpawn for all instances in the event ownership or
419-
// authority changes. When serializing, IsDirtyCount determines how many AnimationState entries
420-
// should be serialized from the list. When deserializing the list is created and populated with
425+
// authority changes. When serializing, IsDirtyCount determines how many AnimationState entries
426+
// should be serialized from the list. When deserializing the list is created and populated with
421427
// only the number of AnimationStates received which is dictated by the deserialized IsDirtyCount.
422428
internal List<AnimationState> AnimationStates;
423429

@@ -493,7 +499,7 @@ internal bool IsServerAuthoritative()
493499
}
494500

495501
/// <summary>
496-
/// Override this method and return false to switch to owner authoritative mode
502+
/// Override this method and return false to switch to owner authoritative mode.
497503
/// </summary>
498504
/// <remarks>
499505
/// When using a distributed authority network topology, this will default to
@@ -731,7 +737,7 @@ public override void OnNetworkDespawn()
731737
}
732738

733739
/// <summary>
734-
/// Wries all parameter and state information needed to initially synchronize a client
740+
/// Writes all parameter and state information needed to initially synchronize a client
735741
/// </summary>
736742
private void WriteSynchronizationData<T>(ref BufferSerializer<T> serializer) where T : IReaderWriter
737743
{
@@ -806,8 +812,10 @@ private void WriteSynchronizationData<T>(ref BufferSerializer<T> serializer) whe
806812
}
807813
}
808814

809-
animationState.Transition = isInTransition; // The only time this could be set to true
810-
animationState.StateHash = stateHash; // When a transition, this is the originating/starting state
815+
// The only time this could be set to true
816+
animationState.Transition = isInTransition;
817+
// When a transition, this is the originating/starting state
818+
animationState.StateHash = stateHash;
811819
animationState.NormalizedTime = normalizedTime;
812820
animationState.Layer = layer;
813821
animationState.Weight = m_LayerWeights[layer];
@@ -881,7 +889,8 @@ private void CheckForStateChange(int layer)
881889
{
882890
m_TransitionHash[layer] = nt.fullPathHash;
883891
m_AnimationHash[layer] = 0;
884-
animState.DestinationStateHash = nt.fullPathHash; // Next state is the destination state for cross fade
892+
// Next state is the destination state for cross fade
893+
animState.DestinationStateHash = nt.fullPathHash;
885894
animState.CrossFade = true;
886895
animState.Transition = true;
887896
animState.Duration = tt.duration;
@@ -899,7 +908,8 @@ private void CheckForStateChange(int layer)
899908
// first time in this transition for this layer
900909
m_TransitionHash[layer] = tt.fullPathHash;
901910
m_AnimationHash[layer] = 0;
902-
animState.StateHash = tt.fullPathHash; // Transitioning from state
911+
// Transitioning from state
912+
animState.StateHash = tt.fullPathHash;
903913
animState.CrossFade = false;
904914
animState.Transition = true;
905915
animState.NormalizedTime = tt.normalizedTime;
@@ -1115,7 +1125,7 @@ private unsafe void WriteParameters(ref FastBufferWriter writer)
11151125
{
11161126
writer.Seek(0);
11171127
writer.Truncate();
1118-
// Write how many parameter entries we are going to write
1128+
// Write out how many parameter entries to read
11191129
BytePacker.WriteValuePacked(writer, (uint)m_ParametersToUpdate.Count);
11201130
foreach (var parameterIndex in m_ParametersToUpdate)
11211131
{
@@ -1264,7 +1274,7 @@ internal void UpdateAnimationState(AnimationState animationState)
12641274
NetworkLog.LogError($"[DestinationState To Transition Info] Layer ({animationState.Layer}) sub-table does not contain destination state ({animationState.DestinationStateHash})!");
12651275
}
12661276
}
1267-
// For reference, it is valid to have no transition information
1277+
// For reference, it is valid to have no transition information
12681278
//else if (NetworkManager.LogLevel == LogLevel.Developer)
12691279
//{
12701280
// NetworkLog.LogError($"[DestinationState To Transition Info] Layer ({animationState.Layer}) does not exist!");
@@ -1471,7 +1481,7 @@ private void InternalSetTrigger(int hash, bool isSet = true)
14711481

14721482
/// <summary>
14731483
/// Distributed Authority: Internally-called RPC client receiving function to update a trigger when the server wants to forward
1474-
/// a trigger for a client to play / reset
1484+
/// a trigger to a client
14751485
/// </summary>
14761486
/// <param name="animationTriggerMessage">the payload containing the trigger data to apply</param>
14771487
[Rpc(SendTo.NotAuthority)]
@@ -1482,7 +1492,7 @@ internal void SendAnimTriggerRpc(AnimationTriggerMessage animationTriggerMessage
14821492

14831493
/// <summary>
14841494
/// Client Server: Internally-called RPC client receiving function to update a trigger when the server wants to forward
1485-
/// a trigger for a client to play / reset
1495+
/// a trigger to a client
14861496
/// </summary>
14871497
/// <param name="animationTriggerMessage">the payload containing the trigger data to apply</param>
14881498
/// <param name="clientRpcParams">unused</param>
@@ -1548,7 +1558,7 @@ public void SetTrigger(int hash, bool setTrigger = true)
15481558
}
15491559

15501560
/// <summary>
1551-
/// Resets the trigger for the associated animation. See <see cref="SetTrigger(string)">SetTrigger</see> for more on how triggers are special
1561+
/// Resets the trigger for the associated animation. See <see cref="SetTrigger(string)">SetTrigger</see> for more on how triggers are special
15521562
/// </summary>
15531563
/// <param name="triggerName">The string name of the trigger to reset</param>
15541564
public void ResetTrigger(string triggerName)
@@ -1564,4 +1574,5 @@ public void ResetTrigger(int hash)
15641574
}
15651575
}
15661576
}
1567-
#endif // COM_UNITY_MODULES_ANIMATION
1577+
// COM_UNITY_MODULES_ANIMATION
1578+
#endif

com.unity.netcode.gameobjects/Runtime/Components/NetworkRigidBodyBase.cs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ internal Vector3 GetAdjustedRotationThreshold()
180180
/// </summary>
181181
/// <remarks>
182182
/// For <see cref="Rigidbody2D"/>, only the x and y components of the <see cref="Vector3"/> are applied.
183-
/// </remarks>
183+
/// </remarks>
184184
public void SetLinearVelocity(Vector3 linearVelocity)
185185
{
186186
if (m_IsRigidbody2D)
@@ -546,7 +546,7 @@ public void SetIsKinematic(bool isKinematic)
546546
{
547547
if (IsKinematic())
548548
{
549-
// If not already set to interpolate then set the Rigidbody to interpolate
549+
// If not already set to interpolate then set the Rigidbody to interpolate
550550
if (m_InternalRigidbody.interpolation == RigidbodyInterpolation.Extrapolate)
551551
{
552552
// Sleep until the next fixed update when switching from extrapolation to interpolation
@@ -849,36 +849,30 @@ public void DetachFromFixedJoint()
849849
}
850850
if (UseRigidBodyForMotion)
851851
{
852-
if (m_IsRigidbody2D)
852+
if (m_IsRigidbody2D && FixedJoint2D != null)
853853
{
854-
if (FixedJoint2D != null)
854+
if (!m_FixedJoint2DUsingGravity)
855855
{
856-
if (!m_FixedJoint2DUsingGravity)
857-
{
858-
FixedJoint2D.connectedBody.gravityScale = m_OriginalGravityScale;
859-
}
860-
FixedJoint2D.connectedBody = null;
861-
Destroy(FixedJoint2D);
862-
FixedJoint2D = null;
863-
ResetInterpolation();
864-
RemoveFromParentBody();
856+
FixedJoint2D.connectedBody.gravityScale = m_OriginalGravityScale;
865857
}
858+
FixedJoint2D.connectedBody = null;
859+
Destroy(FixedJoint2D);
860+
FixedJoint2D = null;
861+
ResetInterpolation();
862+
RemoveFromParentBody();
866863
}
867-
else
864+
else if (FixedJoint != null)
868865
{
869-
if (FixedJoint != null)
870-
{
871-
FixedJoint.connectedBody = null;
872-
m_InternalRigidbody.useGravity = m_OriginalGravitySetting;
873-
Destroy(FixedJoint);
874-
FixedJoint = null;
875-
ResetInterpolation();
876-
RemoveFromParentBody();
877-
}
866+
FixedJoint.connectedBody = null;
867+
m_InternalRigidbody.useGravity = m_OriginalGravitySetting;
868+
Destroy(FixedJoint);
869+
FixedJoint = null;
870+
ResetInterpolation();
871+
RemoveFromParentBody();
878872
}
879873
}
880874
}
881875
}
882876
}
883-
#endif // COM_UNITY_MODULES_PHYSICS
884-
877+
// COM_UNITY_MODULES_PHYSICS
878+
#endif

0 commit comments

Comments
 (0)