@@ -18,10 +18,21 @@ public class NetworkAnimatorTests : BaseMultiInstanceTest
1818 private Animator m_PlayerOnServerAnimator ;
1919 private Animator m_PlayerOnClientAnimator ;
2020
21+
2122 [ UnitySetUp ]
2223 public override IEnumerator Setup ( )
2324 {
24- yield return StartSomeClientsAndServerWithPlayers ( useHost : true , nbClients : NbClients ,
25+ // this is treacherous...normally BaseMultiInstance calls StartSomeClientsAndServerWithPlayers for you
26+ // in its version of Setup. In this case, I want to alternatively test Server and Host mode via parameters
27+ // in each test. However I cannot inject the host / server mode into the corresponding Setup calls, hence
28+ // I wrote and manually call an Init function. However, if I don't write this null version of setup
29+ // I will get 2 calls to StartSomeClientsAndServerWithPlayers, which wrecks everything.
30+ yield return null ;
31+ }
32+
33+ public IEnumerator Init ( bool hostMode )
34+ {
35+ yield return StartSomeClientsAndServerWithPlayers ( useHost : hostMode , nbClients : NbClients ,
2536 updatePlayerPrefab : playerPrefab =>
2637 {
2738 // ideally, we would build up the AnimatorController entirely in code and not need an asset,
@@ -63,8 +74,10 @@ private bool HasClip(Animator animator, string clipName)
6374 }
6475
6576 [ UnityTest ]
66- public IEnumerator AnimationTriggerReset ( [ Values ( true , false ) ] bool asHash )
77+ public IEnumerator AnimationTriggerReset ( [ Values ( true , false ) ] bool asHash , [ Values ( true , false ) ] bool hostMode )
6778 {
79+ yield return Init ( hostMode ) ;
80+
6881 // We have "UnboundTrigger" purposely not bound to any animations so we can test resetting.
6982 // If we used a trigger that was bound to a transition, then the trigger would reset as soon as the
7083 // transition happens. This way it will stay stuck on
@@ -114,9 +127,12 @@ public IEnumerator AnimationTriggerReset([Values(true, false)] bool asHash)
114127 Assert . False ( s_GloabalTimeOutHelper . TimedOut , "Timed out on client reset check" ) ;
115128 }
116129
130+
117131 [ UnityTest ]
118- public IEnumerator AnimationStateSyncTest ( )
132+ public IEnumerator AnimationStateSyncTest ( [ Values ( true , false ) ] bool hostMode )
119133 {
134+ yield return Init ( hostMode ) ;
135+
120136 // check that we have started in the default state
121137 Assert . True ( m_PlayerOnServerAnimator . GetCurrentAnimatorStateInfo ( 0 ) . IsName ( "DefaultState" ) ) ;
122138 Assert . True ( m_PlayerOnClientAnimator . GetCurrentAnimatorStateInfo ( 0 ) . IsName ( "DefaultState" ) ) ;
@@ -137,8 +153,10 @@ public IEnumerator AnimationStateSyncTest()
137153 }
138154
139155 [ UnityTest ]
140- public IEnumerator AnimationStateSyncTriggerTest ( [ Values ( true , false ) ] bool asHash )
156+ public IEnumerator AnimationStateSyncTriggerTest ( [ Values ( true , false ) ] bool asHash , [ Values ( true , false ) ] bool hostMode )
141157 {
158+ yield return Init ( hostMode ) ;
159+
142160 string triggerString = "TestTrigger" ;
143161 int triggerHash = Animator . StringToHash ( triggerString ) ;
144162
@@ -172,8 +190,9 @@ public IEnumerator AnimationStateSyncTriggerTest([Values(true, false)] bool asHa
172190 }
173191
174192 [ UnityTest ]
175- public IEnumerator AnimationStateSyncTestWithOverride ( )
193+ public IEnumerator AnimationStateSyncTestWithOverride ( [ Values ( true , false ) ] bool hostMode )
176194 {
195+ yield return Init ( hostMode ) ;
177196 // set up the animation override controller
178197 var overrideController = Resources . Load ( "TestAnimatorOverrideController" ) as AnimatorOverrideController ;
179198 m_PlayerOnServer . GetComponent < Animator > ( ) . runtimeAnimatorController = overrideController ;
0 commit comments