Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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]
## [1.4.0] - 2023-04-10

### Added

Expand Down Expand Up @@ -41,6 +41,8 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- Fixed issue where `NetworkAnimator` was not properly detecting and synchronizing cross fade initiated transitions. (#2481)
- Fixed issue where `NetworkAnimator` was not properly synchronizing animation state updates. (#2481)
- Fixed an issue where Named Message Handlers could remove themselves causing an exception when the metrics tried to access the name of the message.(#2426)
- Fixed registry of public `NetworkVariable`s in derived `NetworkBehaviour`s (#2423)
- Fixed issue where runtime association of `Animator` properties to `AnimationCurve`s would cause `NetworkAnimator` to attempt to update those changes. (#2416)
Expand All @@ -51,7 +53,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
- Fixed issue where a client would load duplicate scenes of already preloaded scenes during the initial client synchronization and `NetworkSceneManager.ClientSynchronizationMode` was set to `LoadSceneMode.Additive`. (#2383)
- Fixed float NetworkVariables not being rendered properly in the inspector of NetworkObjects. (#2441)

## [1.3.0] - 2023-03-20
## [1.3.1] - 2023-03-27

### Added

Expand Down
334 changes: 165 additions & 169 deletions com.unity.netcode.gameobjects/Components/NetworkAnimator.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ private void ConfigureSimulatorForUtp1()
private string m_ClientCaCertificate;

/// <summary>Set the server parameters for encryption.</summary>
/// <remarks>
/// The public certificate and private key are expected to be in the PEM format, including
/// the begin/end markers like <c>-----BEGIN CERTIFICATE-----</c>.
/// </remarks>
/// <param name="serverCertificate">Public certificate for the server (PEM format).</param>
/// <param name="serverPrivateKey">Private key for the server (PEM format).</param>
public void SetServerSecrets(string serverCertificate, string serverPrivateKey)
Expand All @@ -1442,9 +1446,15 @@ public void SetServerSecrets(string serverCertificate, string serverPrivateKey)

/// <summary>Set the client parameters for encryption.</summary>
/// <remarks>
/// <para>
/// If the CA certificate is not provided, validation will be done against the OS/browser
/// certificate store. This is what you'd want if using certificates from a known provider.
/// For self-signed certificates, the CA certificate needs to be provided.
/// </para>
/// <para>
/// The CA certificate (if provided) is expected to be in the PEM format, including the
/// begin/end markers like <c>-----BEGIN CERTIFICATE-----</c>.
/// </para>
/// </remarks>
/// <param name="serverCommonName">Common name of the server (typically hostname).</param>
/// <param name="caCertificate">CA certificate used to validate the server's authenticity.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,11 @@ public void Dispose()
}
}
QueuedSceneJobs.Clear();
Object.Destroy(CoroutineRunner.gameObject);
if (CoroutineRunner != null && CoroutineRunner.gameObject != null)
{
Object.Destroy(CoroutineRunner.gameObject);
}

}
}
}
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.unity.netcode.gameobjects",
"displayName": "Netcode for GameObjects",
"description": "Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.",
"version": "1.3.0",
"version": "1.3.1",
"unity": "2020.3",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ private float GetLayerWeight(int layer)
return m_Animator.GetLayerWeight(layer);
}

[ServerRpc]
private void TestCrossFadeServerRpc()
{
m_Animator.CrossFade("CrossFadeState", 0.25f, 0);
}

private void TestCrossFade()
{
if (!IsServer && m_IsServerAuthoritative)
{
TestCrossFadeServerRpc();
}
else
{
m_Animator.CrossFade("CrossFadeState", 0.25f, 0);
}
}

private void LateUpdate()
{

Expand All @@ -209,6 +227,11 @@ private void LateUpdate()

DisplayTestIntValueIfChanged();

if (Input.GetKeyDown(KeyCode.G))
{
TestCrossFade();
}

// Rotates the cube
if (Input.GetKeyDown(KeyCode.C))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;

/// <summary>
/// This StateMachineBehaviour is used to detect an <see cref="Animator.CrossFade"/> initiated transition
/// for integration test purposes.
/// </summary>
public class CrossFadeTransitionDetect : StateMachineBehaviour
{
public static Dictionary<ulong, Dictionary<int, AnimatorStateInfo>> StatesEntered = new Dictionary<ulong, Dictionary<int, AnimatorStateInfo>>();
public static bool IsVerboseDebug;

public static string CurrentTargetStateName { get; private set; }
public static int CurrentTargetStateHash { get; private set; }

public static List<ulong> ClientIds = new List<ulong>();

public static void ResetTest()
{
ClientIds.Clear();
StatesEntered.Clear();
IsVerboseDebug = false;
}

private void Log(string logMessage)
{
if (!IsVerboseDebug)
{
return;
}
Debug.Log($"[CrossFadeDetect] {logMessage}");
}

public static bool AllClientsTransitioned()
{
foreach (var clientId in ClientIds)
{
if (!StatesEntered.ContainsKey(clientId))
{
return false;
}

if (!StatesEntered[clientId].ContainsKey(CurrentTargetStateHash))
{
return false;
}
}
return true;
}

public static void SetTargetAnimationState(string animationStateName)
{
CurrentTargetStateName = animationStateName;
CurrentTargetStateHash = Animator.StringToHash(animationStateName);
}

public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.shortNameHash != CurrentTargetStateHash)
{
Log($"[Ignoring State][Layer-{layerIndex}] Incoming: ({stateInfo.fullPathHash}) | Targeting: ({CurrentTargetStateHash})");
return;
}

var networkObject = animator.GetComponent<NetworkObject>();
if (networkObject == null || networkObject.NetworkManager == null || !networkObject.IsSpawned)
{
return;
}

var clientId = networkObject.NetworkManager.LocalClientId;
if (!StatesEntered.ContainsKey(clientId))
{
StatesEntered.Add(clientId, new Dictionary<int, AnimatorStateInfo>());
}

if (!StatesEntered[clientId].ContainsKey(stateInfo.shortNameHash))
{
StatesEntered[clientId].Add(stateInfo.shortNameHash, stateInfo);
}
else
{
StatesEntered[clientId][stateInfo.shortNameHash] = stateInfo;
}

Log($"[{layerIndex}][STATE-ENTER][{clientId}] {networkObject.NetworkManager.name} entered state {stateInfo.shortNameHash}!");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,34 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &-7324519211837832008
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CrossFadeState
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -5899436739107315318}
m_StateMachineBehaviours:
- {fileID: 8360333217518347423}
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: bd13c1363af7aaf4db0ffb085ac89d77, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-6396453490711135124
AnimatorStateTransition:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -238,6 +266,28 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-5899436739107315318
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1676030328622575462}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-5552815716159021554
AnimatorState:
serializedVersion: 6
Expand Down Expand Up @@ -629,6 +679,9 @@ AnimatorStateMachine:
- serializedVersion: 1
m_State: {fileID: -1603678049383302394}
m_Position: {x: 440, y: 190, z: 0}
- serializedVersion: 1
m_State: {fileID: -7324519211837832008}
m_Position: {x: 570, y: -140, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
Expand Down Expand Up @@ -1266,3 +1319,15 @@ AnimatorStateMachine:
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 5205197960406981613}
--- !u!114 &8360333217518347423
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53314cafa8e073c40b0b35dd25485c42, type: 3}
m_Name:
m_EditorClassIdentifier:
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public void SetTrigger(string name = "TestTrigger", bool monitorTrigger = false)
}
}

public const string TargetCrossFadeState = "CrossFadeState";

public void TestCrossFade()
{
m_Animator.CrossFade(TargetCrossFadeState, 0.25f, 0);
}

public void SetBool(string name, bool valueToSet)
{
m_Animator.SetBool(name, valueToSet);
Expand Down
Loading