@@ -521,6 +521,7 @@ protected virtual bool OnIsServerAuthoritative()
521521
522522 private unsafe struct AnimatorParamCache
523523 {
524+ internal bool Exclude ;
524525 internal int Hash ;
525526 internal int Type ;
526527 internal fixed byte Value [ 4 ] ; // this is a max size of 4 bytes
@@ -1064,6 +1065,11 @@ private unsafe bool CheckParametersChanged()
10641065 {
10651066 ref var cacheValue = ref UnsafeUtility . ArrayElementAsRef < AnimatorParamCache > ( m_CachedAnimatorParameters . GetUnsafePtr ( ) , i ) ;
10661067
1068+ if ( cacheValue . Exclude )
1069+ {
1070+ continue ;
1071+ }
1072+
10671073 // If a parameter gets controlled by a curve during runtime after initialization of NetworkAnimator
10681074 // then ignore changes to this parameter. We are not removing the parameter in the event that
10691075 // it no longer is controlled by a curve.
@@ -1562,6 +1568,32 @@ public void ResetTrigger(int hash)
15621568 {
15631569 SetTrigger ( hash , false ) ;
15641570 }
1571+
1572+ /// <summary>
1573+ /// Allows for the enabling or disabling the synchronization of a specific
1574+ /// <see cref="Animator"/> parameter.
1575+ /// </summary>
1576+ /// <param name="parameterName">name of the parameter</param>
1577+ /// <param name="enable">whether to enable or disable synchronizing it</param>
1578+ public void ToggleParameterSync ( string parameterName , bool enable )
1579+ {
1580+ var serverAuthoritative = OnIsServerAuthoritative ( ) ;
1581+ if ( ! IsSpawned || serverAuthoritative && IsServer || ! serverAuthoritative && IsOwner )
1582+ {
1583+ var hash32 = Animator . StringToHash ( parameterName ) ;
1584+
1585+ for ( int i = 0 ; i < m_CachedAnimatorParameters . Length ; i ++ )
1586+ {
1587+ var cachedParameter = m_CachedAnimatorParameters [ i ] ;
1588+ if ( cachedParameter . Hash == hash32 )
1589+ {
1590+ cachedParameter . Exclude = ! enable ;
1591+ m_CachedAnimatorParameters [ i ] = cachedParameter ;
1592+ break ;
1593+ }
1594+ }
1595+ }
1596+ }
15651597 }
15661598}
15671599#endif // COM_UNITY_MODULES_ANIMATION
0 commit comments