com.unity.netcode.gameobjects@2.0.0
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [2.0.0] - 2024-09-12 ### Added - Added tooltips for all of the `NetworkObject` component's properties. (#3052) - Added message size validation to named and unnamed message sending functions for better error messages. (#3049) - Added "Check for NetworkObject Component" property to the Multiplayer->Netcode for GameObjects project settings. When disabled, this will bypass the in-editor `NetworkObject` check on `NetworkBehaviour` components. (#3031) - Added `NetworkTransform.SwitchTransformSpaceWhenParented` property that, when enabled, will handle the world to local, local to world, and local to local transform space transitions when interpolation is enabled. (#3013) - Added `NetworkTransform.TickSyncChildren` that, when enabled, will tick synchronize nested and/or child `NetworkTransform` components to eliminate any potential visual jittering that could occur if the `NetworkTransform` instances get into a state where their state updates are landing on different network ticks. (#3013) - Added `NetworkObject.AllowOwnerToParent` property to provide the ability to allow clients to parent owned objects when running in a client-server network topology. (#3013) - Added `NetworkObject.SyncOwnerTransformWhenParented` property to provide a way to disable applying the server's transform information in the parenting message on the client owner instance which can be useful for owner authoritative motion models. (#3013) - Added `NetcodeEditorBase` editor helper class to provide easier modification and extension of the SDK's components. (#3013) ### Fixed - Fixed issue where `NetworkAnimator` would send updates to non-observer clients. (#3057) - Fixed issue where an exception could occur when receiving a universal RPC for a `NetworkObject` that has been despawned. (#3052) - Fixed issue where a NetworkObject hidden from a client that is then promoted to be session owner was not being synchronized with newly joining clients.(#3051) - Fixed issue where clients could have a wrong time delta on `NetworkVariableBase` which could prevent from sending delta state updates. (#3045) - Fixed issue where setting a prefab hash value during connection approval but not having a player prefab assigned could cause an exception when spawning a player. (#3042) - Fixed issue where the `NetworkSpawnManager.HandleNetworkObjectShow` could throw an exception if one of the `NetworkObject` components to show was destroyed during the same frame. (#3030) - Fixed issue where the `NetworkManagerHelper` was continuing to check for hierarchy changes when in play mode. (#3026) - Fixed issue with newly/late joined clients and `NetworkTransform` synchronization of parented `NetworkObject` instances. (#3013) - Fixed issue with smooth transitions between transform spaces when interpolation is enabled (requires `NetworkTransform.SwitchTransformSpaceWhenParented` to be enabled). (#3013) ### Changed - Changed `NetworkTransformEditor` now uses `NetworkTransform` as the base type class to assure it doesn't display a foldout group when using the base `NetworkTransform` component class. (#3052) - Changed `NetworkAnimator.Awake` is now a protected virtual method. (#3052) - Changed when invoking `NetworkManager.ConnectionManager.DisconnectClient` during a distributed authority session a more appropriate message is logged. (#3052) - Changed `NetworkTransformEditor` so it now derives from `NetcodeEditorBase`. (#3013) - Changed `NetworkRigidbodyBaseEditor` so it now derives from `NetcodeEditorBase`. (#3013) - Changed `NetworkManagerEditor` so it now derives from `NetcodeEditorBase`. (#3013)
This commit is contained in:
@@ -19,6 +19,12 @@ namespace Unity.Netcode
|
||||
/// </summary>
|
||||
public abstract class NetworkBehaviour : MonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[HideInInspector]
|
||||
[SerializeField]
|
||||
internal bool ShowTopMostFoldoutHeaderGroup = true;
|
||||
#endif
|
||||
|
||||
#pragma warning disable IDE1006 // disable naming rule violation check
|
||||
|
||||
// RuntimeAccessModifiersILPP will make this `public`
|
||||
@@ -688,6 +694,8 @@ namespace Unity.Netcode
|
||||
/// </remarks>
|
||||
protected virtual void OnNetworkPostSpawn() { }
|
||||
|
||||
protected internal virtual void InternalOnNetworkPostSpawn() { }
|
||||
|
||||
/// <summary>
|
||||
/// This method is only available client-side.
|
||||
/// When a new client joins it's synchronized with all spawned NetworkObjects and scenes loaded for the session joined. At the end of the synchronization process, when all
|
||||
@@ -700,6 +708,8 @@ namespace Unity.Netcode
|
||||
/// </remarks>
|
||||
protected virtual void OnNetworkSessionSynchronized() { }
|
||||
|
||||
protected internal virtual void InternalOnNetworkSessionSynchronized() { }
|
||||
|
||||
/// <summary>
|
||||
/// When a scene is loaded and in-scene placed NetworkObjects are finished spawning, this method is invoked on all of the newly spawned in-scene placed NetworkObjects.
|
||||
/// This method runs both client and server side.
|
||||
@@ -759,6 +769,7 @@ namespace Unity.Netcode
|
||||
{
|
||||
try
|
||||
{
|
||||
InternalOnNetworkPostSpawn();
|
||||
OnNetworkPostSpawn();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -771,6 +782,7 @@ namespace Unity.Netcode
|
||||
{
|
||||
try
|
||||
{
|
||||
InternalOnNetworkSessionSynchronized();
|
||||
OnNetworkSessionSynchronized();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -853,6 +865,8 @@ namespace Unity.Netcode
|
||||
/// <param name="parentNetworkObject">the new <see cref="NetworkObject"/> parent</param>
|
||||
public virtual void OnNetworkObjectParentChanged(NetworkObject parentNetworkObject) { }
|
||||
|
||||
internal virtual void InternalOnNetworkObjectParentChanged(NetworkObject parentNetworkObject) { }
|
||||
|
||||
private bool m_VarInit = false;
|
||||
|
||||
private readonly List<HashSet<int>> m_DeliveryMappedNetworkVariableIndices = new List<HashSet<int>>();
|
||||
|
||||
@@ -17,6 +17,12 @@ namespace Unity.Netcode
|
||||
[AddComponentMenu("Netcode/Network Manager", -100)]
|
||||
public class NetworkManager : MonoBehaviour, INetworkUpdateSystem
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Inspector view expand/collapse settings for this derived child class
|
||||
[HideInInspector]
|
||||
public bool NetworkManagerExpanded;
|
||||
#endif
|
||||
|
||||
// TODO: Deprecate...
|
||||
// The following internal values are not used, but because ILPP makes them public in the assembly, they cannot
|
||||
// be removed thanks to our semver validation.
|
||||
@@ -189,7 +195,6 @@ namespace Unity.Netcode
|
||||
OnSessionOwnerPromoted?.Invoke(sessionOwner);
|
||||
}
|
||||
|
||||
// TODO: Make this internal after testing
|
||||
internal void PromoteSessionOwner(ulong clientId)
|
||||
{
|
||||
if (!DistributedAuthorityMode)
|
||||
@@ -890,6 +895,11 @@ namespace Unity.Netcode
|
||||
OnNetworkManagerReset?.Invoke(this);
|
||||
}
|
||||
|
||||
protected virtual void OnValidateComponent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal void OnValidate()
|
||||
{
|
||||
if (NetworkConfig == null)
|
||||
@@ -950,6 +960,15 @@ namespace Unity.Netcode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OnValidateComponent();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void ModeChanged(PlayModeStateChange change)
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace Unity.Netcode
|
||||
/// </remarks>
|
||||
public List<NetworkTransform> NetworkTransforms { get; private set; }
|
||||
|
||||
|
||||
#if COM_UNITY_MODULES_PHYSICS
|
||||
/// <summary>
|
||||
/// All <see cref="NetworkRigidbodyBase"></see> component instances associated with a <see cref="NetworkObject"/> component instance.
|
||||
@@ -937,6 +938,7 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// If true, the object will always be replicated as root on clients and the parent will be ignored.
|
||||
/// </summary>
|
||||
[Tooltip("If enabled (default disabled), instances of this NetworkObject will ignore any parent(s) it might have and replicate on clients as the root being its parent.")]
|
||||
public bool AlwaysReplicateAsRoot;
|
||||
|
||||
/// <summary>
|
||||
@@ -954,6 +956,8 @@ namespace Unity.Netcode
|
||||
/// bandwidth cost. This can also be useful for UI elements that have
|
||||
/// a predetermined fixed position.
|
||||
/// </remarks>
|
||||
[Tooltip("If enabled (default enabled), newly joining clients will be synchronized with the transform of the associated GameObject this component is attached to. Typical use case" +
|
||||
" scenario would be for managment objects or in-scene placed objects that don't move and already have their transform settings applied within the scene information.")]
|
||||
public bool SynchronizeTransform = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -1011,6 +1015,7 @@ namespace Unity.Netcode
|
||||
/// To synchronize clients of a <see cref="NetworkObject"/>'s scene being changed via <see cref="SceneManager.MoveGameObjectToScene(GameObject, Scene)"/>,
|
||||
/// make sure <see cref="SceneMigrationSynchronization"/> is enabled (it is by default).
|
||||
/// </remarks>
|
||||
[Tooltip("When enabled (default disabled), spawned instances of this NetworkObject will automatically migrate to any newly assigned active scene.")]
|
||||
public bool ActiveSceneSynchronization;
|
||||
|
||||
/// <summary>
|
||||
@@ -1029,6 +1034,7 @@ namespace Unity.Netcode
|
||||
/// is <see cref="true"/> and <see cref="ActiveSceneSynchronization"/> is <see cref="false"/> and the scene is not the currently
|
||||
/// active scene, then the <see cref="NetworkObject"/> will be destroyed.
|
||||
/// </remarks>
|
||||
[Tooltip("When enabled (default enabled), dynamically spawned instances of this NetworkObject's migration to a different scene will automatically be synchonize amongst clients.")]
|
||||
public bool SceneMigrationSynchronization = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -1044,7 +1050,7 @@ namespace Unity.Netcode
|
||||
/// <summary>
|
||||
/// When set to false, the NetworkObject will be spawned with no observers initially (other than the server)
|
||||
/// </summary>
|
||||
[Tooltip("When false, the NetworkObject will spawn with no observers initially. (default is true)")]
|
||||
[Tooltip("When disabled (default enabled), the NetworkObject will spawn with no observers. You control object visibility using NetworkShow. This applies to newly joining clients as well.")]
|
||||
public bool SpawnWithObservers = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -1073,13 +1079,35 @@ namespace Unity.Netcode
|
||||
/// Whether or not to destroy this object if it's owner is destroyed.
|
||||
/// If true, the objects ownership will be given to the server.
|
||||
/// </summary>
|
||||
[Tooltip("When enabled (default disabled), instances of this NetworkObject will not be destroyed if the owning client disconnects.")]
|
||||
public bool DontDestroyWithOwner;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to enable automatic NetworkObject parent synchronization.
|
||||
/// </summary>
|
||||
[Tooltip("When disabled (default enabled), NetworkObject parenting will not be automatically synchronized. This is typically used when you want to implement your own custom parenting solution.")]
|
||||
public bool AutoObjectParentSync = true;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the owner will apply transform values sent by the parenting message.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When enabled, the resultant parenting transform changes sent by the authority will be applied on all instances. <br />
|
||||
/// When disabled, the resultant parenting transform changes sent by the authority will not be applied on the owner's instance. <br />
|
||||
/// When disabled, all non-owner instances will still be synchronized by the authority's transform values when parented.
|
||||
/// When using a <see cref="NetworkTopologyTypes.ClientServer"/> network topology and an owner authoritative motion model, disabling this can help smooth parenting transitions.
|
||||
/// When using a <see cref="NetworkTopologyTypes.DistributedAuthority"/> network topology this will have no impact on the owner's instance since only the authority/owner can parent.
|
||||
/// </remarks>
|
||||
[Tooltip("When disabled (default enabled), the owner will not apply a server or host's transform properties when parenting changes. Primarily useful for client-server network topology configurations.")]
|
||||
public bool SyncOwnerTransformWhenParented = true;
|
||||
|
||||
/// <summary>
|
||||
/// Client-Server specific, when enabled an owner of a NetworkObject can parent locally as opposed to requiring the owner to notify the server it would like to be parented.
|
||||
/// This behavior is always true when using a distributed authority network topology and does not require it to be set.
|
||||
/// </summary>
|
||||
[Tooltip("When enabled (default disabled), owner's can parent a NetworkObject locally without having to send an RPC to the server or host. Only pertinent when using client-server network topology configurations.")]
|
||||
public bool AllowOwnerToParent;
|
||||
|
||||
internal readonly HashSet<ulong> Observers = new HashSet<ulong>();
|
||||
|
||||
#if MULTIPLAYER_TOOLS
|
||||
@@ -1787,6 +1815,9 @@ namespace Unity.Netcode
|
||||
{
|
||||
for (int i = 0; i < ChildNetworkBehaviours.Count; i++)
|
||||
{
|
||||
// Invoke internal notification
|
||||
ChildNetworkBehaviours[i].InternalOnNetworkObjectParentChanged(parentNetworkObject);
|
||||
// Invoke public notification
|
||||
ChildNetworkBehaviours[i].OnNetworkObjectParentChanged(parentNetworkObject);
|
||||
}
|
||||
}
|
||||
@@ -1918,7 +1949,7 @@ namespace Unity.Netcode
|
||||
|
||||
// DANGO-TODO: Do we want to worry about ownership permissions here?
|
||||
// It wouldn't make sense to not allow parenting, but keeping this note here as a reminder.
|
||||
var isAuthority = HasAuthority;
|
||||
var isAuthority = HasAuthority || (AllowOwnerToParent && IsOwner);
|
||||
|
||||
// If we don't have authority and we are not shutting down, then don't allow any parenting.
|
||||
// If we are shutting down and don't have authority then allow it.
|
||||
@@ -1984,7 +2015,7 @@ namespace Unity.Netcode
|
||||
var isAuthority = false;
|
||||
// With distributed authority, we need to track "valid authoritative" parenting changes.
|
||||
// So, either the authority or AuthorityAppliedParenting is considered a "valid parenting change".
|
||||
isAuthority = HasAuthority || AuthorityAppliedParenting;
|
||||
isAuthority = HasAuthority || AuthorityAppliedParenting || (AllowOwnerToParent && IsOwner);
|
||||
var distributedAuthority = NetworkManager.DistributedAuthorityMode;
|
||||
|
||||
// If we do not have authority and we are spawned
|
||||
@@ -2076,7 +2107,7 @@ namespace Unity.Netcode
|
||||
}
|
||||
|
||||
// If we are connected to a CMB service or we are running a mock CMB service then send to the "server" identifier
|
||||
if (distributedAuthority)
|
||||
if (distributedAuthority || (!distributedAuthority && AllowOwnerToParent && IsOwner && !NetworkManager.IsServer))
|
||||
{
|
||||
if (!NetworkManager.DAHost)
|
||||
{
|
||||
@@ -2365,7 +2396,9 @@ namespace Unity.Netcode
|
||||
{
|
||||
NetworkTransforms = new List<NetworkTransform>();
|
||||
}
|
||||
NetworkTransforms.Add(networkBehaviours[i] as NetworkTransform);
|
||||
var networkTransform = networkBehaviours[i] as NetworkTransform;
|
||||
networkTransform.IsNested = i != 0 && networkTransform.gameObject != gameObject;
|
||||
NetworkTransforms.Add(networkTransform);
|
||||
}
|
||||
#if COM_UNITY_MODULES_PHYSICS
|
||||
else if (type.IsSubclassOf(typeof(NetworkRigidbodyBase)))
|
||||
|
||||
Reference in New Issue
Block a user