Skip to content

chore: merge release 2.2.0 back into develop-2.0.0 #3179

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
Merged
20 changes: 16 additions & 4 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

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

[Unreleased]
## [Unreleased]

### Added

### Fixed

### Changed


## [2.2.0] - 2024-12-12

### Added

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

### Fixed

- 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)
- 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)
- Fixed issue where a sever only `NetworkManager` instance would spawn the actual `NetworkPrefab`'s `GameObject` as opposed to creating an instance of it. (#3160)
- 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)
Expand Down Expand Up @@ -216,8 +226,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
## [2.0.0-exp.2] - 2024-04-02

### Added
- Added updates to all internal messages to account for a distributed authority network session connection. (#2863)
- 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)
- Added updates to all internal messages to account for a distributed authority network session connection. (#2863)
- 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)
- For a customized `NetworkRigidbodyBase` class:
- `NetworkRigidbodyBase.AutoUpdateKinematicState` provides control on whether the kinematic setting will be automatically set or not when ownership changes.
- `NetworkRigidbodyBase.AutoSetKinematicOnDespawn` provides control on whether isKinematic will automatically be set to true when the associated `NetworkObject` is despawned.
Expand Down Expand Up @@ -353,6 +363,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
- Fixed issue where you could not have multiple source network prefab overrides targeting the same network prefab as their override. (#2710)

### Changed

- 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)
- 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)
- Changed `NetworkTransform.SetState` (and related methods) now are cumulative during a fractional tick period and sent on the next pending tick. (#2777)
Expand All @@ -365,6 +376,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
- Changed in-scene placed `NetworkObject`s now set their `IsSceneObject` value when generating their `GlobalObjectIdHash` value. (#2710)
- Changed the default `NetworkConfig.SpawnTimeout` value from 1.0s to 10.0s. (#2710)


## [1.7.1] - 2023-11-15

### Added
Expand Down Expand Up @@ -414,7 +426,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
### Added

- Added a protected virtual method `NetworkTransform.OnInitialize(ref NetworkTransformState replicatedState)` that just returns the replicated state reference.

### Fixed

- 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void DisplayNetworkManagerProperties()
if (m_NetworkManager.NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority)
{
EditorGUILayout.PropertyField(m_AutoSpawnPlayerPrefabClientSide, new GUIContent("Auto Spawn Player Prefab"));
}
}
#endif
EditorGUILayout.PropertyField(m_PlayerPrefabProperty, new GUIContent("Default Player Prefab"));

Expand Down
4 changes: 2 additions & 2 deletions com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
// The below can cause visual anomalies and/or throws an exception within the EditorGUI itself (index out of bounds of the array). and has
// 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
// even though if you exit the popup menu the flag setting is correct.
//var ownership = (NetworkObject.OwnershipStatus)EditorGUI.EnumFlagsField(position, label, (NetworkObject.OwnershipStatus)property.enumValueFlag);
//property.enumValueFlag = (int)ownership;
// var ownership = (NetworkObject.OwnershipStatus)EditorGUI.EnumFlagsField(position, label, (NetworkObject.OwnershipStatus)property.enumValueFlag);
// property.enumValueFlag = (int)ownership;
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();
}
Expand Down
4 changes: 1 addition & 3 deletions com.unity.netcode.gameobjects/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Unity Companion License (UCL License)

com.unity.netcode.gameobjects copyright © 2021-2024 Unity Technologies
com.unity.netcode.gameobjects copyright © 2024 Unity Technologies
Licensed under the Unity Companion License for Unity-dependent projects (see https://unity3d.com/legal/licenses/unity_companion_license).
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.


Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,11 @@ private void ParseStateMachineStates(int layerIndex, ref AnimatorController anim
}
}

#endif

/// <summary>
/// Creates the TransitionStateInfoList table
/// </summary>
private void BuildTransitionStateInfoList()
{
#if UNITY_EDITOR
if (m_Animator == null)
{
return;
Expand All @@ -323,17 +320,26 @@ private void BuildTransitionStateInfoList()
var stateMachine = animatorController.layers[x].stateMachine;
ParseStateMachineStates(x, ref animatorController, ref stateMachine);
}
#endif
}

/// <summary>
/// In-Editor Only
/// Virtual OnValidate method for custom derived NetworkAnimator classes.
/// </summary>
protected virtual void OnValidate()
{
BuildTransitionStateInfoList();
}
#endif

public void OnAfterDeserialize()
{
BuildDestinationToTransitionInfoTable();
}

public void OnBeforeSerialize()
{
BuildTransitionStateInfoList();
// Do nothing when serializing (handled during OnValidate)
}

internal struct AnimationState : INetworkSerializable
Expand Down Expand Up @@ -416,8 +422,8 @@ internal struct AnimationMessage : INetworkSerializable
internal bool HasBeenProcessed;

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

Expand Down Expand Up @@ -493,7 +499,7 @@ internal bool IsServerAuthoritative()
}

/// <summary>
/// Override this method and return false to switch to owner authoritative mode
/// Override this method and return false to switch to owner authoritative mode.
/// </summary>
/// <remarks>
/// When using a distributed authority network topology, this will default to
Expand Down Expand Up @@ -731,7 +737,7 @@ public override void OnNetworkDespawn()
}

/// <summary>
/// Wries all parameter and state information needed to initially synchronize a client
/// Writes all parameter and state information needed to initially synchronize a client
/// </summary>
private void WriteSynchronizationData<T>(ref BufferSerializer<T> serializer) where T : IReaderWriter
{
Expand Down Expand Up @@ -806,8 +812,10 @@ private void WriteSynchronizationData<T>(ref BufferSerializer<T> serializer) whe
}
}

animationState.Transition = isInTransition; // The only time this could be set to true
animationState.StateHash = stateHash; // When a transition, this is the originating/starting state
// The only time this could be set to true
animationState.Transition = isInTransition;
// When a transition, this is the originating/starting state
animationState.StateHash = stateHash;
animationState.NormalizedTime = normalizedTime;
animationState.Layer = layer;
animationState.Weight = m_LayerWeights[layer];
Expand Down Expand Up @@ -881,7 +889,8 @@ private void CheckForStateChange(int layer)
{
m_TransitionHash[layer] = nt.fullPathHash;
m_AnimationHash[layer] = 0;
animState.DestinationStateHash = nt.fullPathHash; // Next state is the destination state for cross fade
// Next state is the destination state for cross fade
animState.DestinationStateHash = nt.fullPathHash;
animState.CrossFade = true;
animState.Transition = true;
animState.Duration = tt.duration;
Expand All @@ -899,7 +908,8 @@ private void CheckForStateChange(int layer)
// first time in this transition for this layer
m_TransitionHash[layer] = tt.fullPathHash;
m_AnimationHash[layer] = 0;
animState.StateHash = tt.fullPathHash; // Transitioning from state
// Transitioning from state
animState.StateHash = tt.fullPathHash;
animState.CrossFade = false;
animState.Transition = true;
animState.NormalizedTime = tt.normalizedTime;
Expand Down Expand Up @@ -1115,7 +1125,7 @@ private unsafe void WriteParameters(ref FastBufferWriter writer)
{
writer.Seek(0);
writer.Truncate();
// Write how many parameter entries we are going to write
// Write out how many parameter entries to read
BytePacker.WriteValuePacked(writer, (uint)m_ParametersToUpdate.Count);
foreach (var parameterIndex in m_ParametersToUpdate)
{
Expand Down Expand Up @@ -1264,7 +1274,7 @@ internal void UpdateAnimationState(AnimationState animationState)
NetworkLog.LogError($"[DestinationState To Transition Info] Layer ({animationState.Layer}) sub-table does not contain destination state ({animationState.DestinationStateHash})!");
}
}
// For reference, it is valid to have no transition information
// For reference, it is valid to have no transition information
//else if (NetworkManager.LogLevel == LogLevel.Developer)
//{
// NetworkLog.LogError($"[DestinationState To Transition Info] Layer ({animationState.Layer}) does not exist!");
Expand Down Expand Up @@ -1471,7 +1481,7 @@ private void InternalSetTrigger(int hash, bool isSet = true)

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

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

/// <summary>
/// Resets the trigger for the associated animation. See <see cref="SetTrigger(string)">SetTrigger</see> for more on how triggers are special
/// Resets the trigger for the associated animation. See <see cref="SetTrigger(string)">SetTrigger</see> for more on how triggers are special
/// </summary>
/// <param name="triggerName">The string name of the trigger to reset</param>
public void ResetTrigger(string triggerName)
Expand All @@ -1564,4 +1574,5 @@ public void ResetTrigger(int hash)
}
}
}
#endif // COM_UNITY_MODULES_ANIMATION
// COM_UNITY_MODULES_ANIMATION
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal Vector3 GetAdjustedRotationThreshold()
/// </summary>
/// <remarks>
/// For <see cref="Rigidbody2D"/>, only the x and y components of the <see cref="Vector3"/> are applied.
/// </remarks>
/// </remarks>
public void SetLinearVelocity(Vector3 linearVelocity)
{
if (m_IsRigidbody2D)
Expand Down Expand Up @@ -546,7 +546,7 @@ public void SetIsKinematic(bool isKinematic)
{
if (IsKinematic())
{
// If not already set to interpolate then set the Rigidbody to interpolate
// If not already set to interpolate then set the Rigidbody to interpolate
if (m_InternalRigidbody.interpolation == RigidbodyInterpolation.Extrapolate)
{
// Sleep until the next fixed update when switching from extrapolation to interpolation
Expand Down Expand Up @@ -849,36 +849,30 @@ public void DetachFromFixedJoint()
}
if (UseRigidBodyForMotion)
{
if (m_IsRigidbody2D)
if (m_IsRigidbody2D && FixedJoint2D != null)
{
if (FixedJoint2D != null)
if (!m_FixedJoint2DUsingGravity)
{
if (!m_FixedJoint2DUsingGravity)
{
FixedJoint2D.connectedBody.gravityScale = m_OriginalGravityScale;
}
FixedJoint2D.connectedBody = null;
Destroy(FixedJoint2D);
FixedJoint2D = null;
ResetInterpolation();
RemoveFromParentBody();
FixedJoint2D.connectedBody.gravityScale = m_OriginalGravityScale;
}
FixedJoint2D.connectedBody = null;
Destroy(FixedJoint2D);
FixedJoint2D = null;
ResetInterpolation();
RemoveFromParentBody();
}
else
else if (FixedJoint != null)
{
if (FixedJoint != null)
{
FixedJoint.connectedBody = null;
m_InternalRigidbody.useGravity = m_OriginalGravitySetting;
Destroy(FixedJoint);
FixedJoint = null;
ResetInterpolation();
RemoveFromParentBody();
}
FixedJoint.connectedBody = null;
m_InternalRigidbody.useGravity = m_OriginalGravitySetting;
Destroy(FixedJoint);
FixedJoint = null;
ResetInterpolation();
RemoveFromParentBody();
}
}
}
}
}
#endif // COM_UNITY_MODULES_PHYSICS

// COM_UNITY_MODULES_PHYSICS
#endif
Loading
Loading