Skip to content

Commit 74a9442

Browse files
committed
Fixed issue of RpcTarget not being properly disposed.
1 parent c2e8cd8 commit 74a9442

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ protected virtual bool OnIsServerAuthoritative()
709709
private static byte[] s_EmptyArray = new byte[] { };
710710
private List<int> m_ParametersToUpdate;
711711
private RpcParams m_RpcParams;
712-
private RpcTargetGroup m_TargetGroup;
712+
private IGroupRpcTarget m_TargetGroup;
713713
private AnimationMessage m_AnimationMessage;
714714
private NetworkAnimatorStateChangeHandler m_NetworkAnimatorStateChangeHandler;
715715

@@ -762,7 +762,7 @@ public override void OnDestroy()
762762
{
763763
SpawnCleanup();
764764

765-
m_TargetGroup?.Dispose();
765+
m_TargetGroup?.Target?.Dispose();
766766

767767
if (m_CachedAnimatorParameters != null && m_CachedAnimatorParameters.IsCreated)
768768
{
@@ -928,12 +928,13 @@ public override void OnNetworkSpawn()
928928
NetworkLog.LogWarningServer($"[{gameObject.name}][{nameof(NetworkAnimator)}] {nameof(Animator)} is not assigned! Animation synchronization will not work for this instance!");
929929
}
930930

931-
m_TargetGroup = RpcTarget.Group(new List<ulong>(128), RpcTargetUse.Persistent) as RpcTargetGroup;
931+
m_TargetGroup = RpcTarget.Group(new List<ulong>(128), RpcTargetUse.Persistent) as IGroupRpcTarget;
932932
m_RpcParams = new RpcParams()
933933
{
934934
Send = new RpcSendParams()
935935
{
936-
Target = m_TargetGroup
936+
// FIX: Use m_TargetGroup.Target to get the BaseRpcTarget
937+
Target = m_TargetGroup?.Target
937938
}
938939
};
939940

@@ -1219,7 +1220,7 @@ internal void CheckForAnimatorChanges()
12191220
}
12201221
m_TargetGroup.Add(clientId);
12211222
}
1222-
m_RpcParams.Send.Target = m_TargetGroup;
1223+
m_RpcParams.Send.Target = m_TargetGroup.Target;
12231224
SendClientAnimStateRpc(m_AnimationMessage, m_RpcParams);
12241225
}
12251226
}
@@ -1555,7 +1556,7 @@ private unsafe void SendServerParametersUpdateRpc(ParametersUpdateMessage parame
15551556
m_TargetGroup.Add(clientId);
15561557
}
15571558

1558-
m_RpcParams.Send.Target = m_TargetGroup;
1559+
m_RpcParams.Send.Target = m_TargetGroup.Target;
15591560
m_NetworkAnimatorStateChangeHandler.SendParameterUpdate(parametersUpdate, m_RpcParams);
15601561
}
15611562
}
@@ -1621,7 +1622,7 @@ private void SendServerAnimStateRpc(AnimationMessage animationMessage, RpcParams
16211622
}
16221623
m_TargetGroup.Add(clientId);
16231624
}
1624-
m_RpcParams.Send.Target = m_TargetGroup;
1625+
m_RpcParams.Send.Target = m_TargetGroup.Target;
16251626
m_NetworkAnimatorStateChangeHandler.SendAnimationUpdate(animationMessage, m_RpcParams);
16261627
}
16271628
}

0 commit comments

Comments
 (0)