fix: NetworkAnimator generating AnimationCurve warnings (#2416)
* fix Don't try to access m_Animator if it is not assigned. Don't try to update animation curves. Now generate a tracking list for all parameters and cull out those controlled by AnimationCurves when checking for deltas.
This commit is contained in:
Родитель
fda40c3338
Коммит
8b8825b278
|
@ -15,6 +15,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
|
|||
### Fixed
|
||||
|
||||
- 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)
|
||||
- Fixed issue where `NetworkAnimator` would not check if its associated `Animator` was valid during serialization and would spam exceptions in the editor console. (#2416)
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -279,6 +279,11 @@ namespace Unity.Netcode.Components
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (m_Animator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TransitionStateInfoList = new List<TransitionStateinfo>();
|
||||
var animatorController = m_Animator.runtimeAnimatorController as AnimatorController;
|
||||
if (animatorController == null)
|
||||
|
@ -588,17 +593,13 @@ namespace Unity.Netcode.Components
|
|||
m_CachedAnimatorParameters = new NativeArray<AnimatorParamCache>(parameters.Length, Allocator.Persistent);
|
||||
m_ParametersToUpdate = new List<int>(parameters.Length);
|
||||
|
||||
// Include all parameters including any controlled by an AnimationCurve as this could change during runtime.
|
||||
// We ignore changes to any parameter controlled by an AnimationCurve when we are checking for changes in
|
||||
// the Animator's parameters.
|
||||
for (var i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
var parameter = parameters[i];
|
||||
|
||||
if (m_Animator.IsParameterControlledByCurve(parameter.nameHash))
|
||||
{
|
||||
// we are ignoring parameters that are controlled by animation curves - syncing the layer
|
||||
// states indirectly syncs the values that are driven by the animation curves
|
||||
continue;
|
||||
}
|
||||
|
||||
var cacheParam = new AnimatorParamCache
|
||||
{
|
||||
Type = UnsafeUtility.EnumToInt(parameter.type),
|
||||
|
@ -643,6 +644,12 @@ namespace Unity.Netcode.Components
|
|||
/// <inheritdoc/>
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
// If there is no assigned Animator then generate a server network warning (logged locally and if applicable on the server-host side as well).
|
||||
if (m_Animator == null)
|
||||
{
|
||||
NetworkLog.LogWarningServer($"[{gameObject.name}][{nameof(NetworkAnimator)}] {nameof(Animator)} is not assigned! Animation synchronization will not work for this instance!");
|
||||
}
|
||||
|
||||
if (IsServer)
|
||||
{
|
||||
m_ClientSendList = new List<ulong>(128);
|
||||
|
@ -906,6 +913,14 @@ namespace Unity.Netcode.Components
|
|||
for (int i = 0; i < m_CachedAnimatorParameters.Length; i++)
|
||||
{
|
||||
ref var cacheValue = ref UnsafeUtility.ArrayElementAsRef<AnimatorParamCache>(m_CachedAnimatorParameters.GetUnsafePtr(), i);
|
||||
|
||||
// If a parameter gets controlled by a curve during runtime after initialization of NetworkAnimator
|
||||
// then ignore changes to this parameter. We are not removing the parameter in the event that
|
||||
// it no longer is controlled by a curve.
|
||||
if (m_Animator.IsParameterControlledByCurve(cacheValue.Hash))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var hash = cacheValue.Hash;
|
||||
if (cacheValue.Type == AnimationParamEnumWrapper.AnimatorControllerParameterInt)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче