@@ -18,10 +18,21 @@ public class NetworkAnimatorTests : BaseMultiInstanceTest
18
18
private Animator m_PlayerOnServerAnimator ;
19
19
private Animator m_PlayerOnClientAnimator ;
20
20
21
+
21
22
[ UnitySetUp ]
22
23
public override IEnumerator Setup ( )
23
24
{
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 ,
25
36
updatePlayerPrefab : playerPrefab =>
26
37
{
27
38
// 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)
63
74
}
64
75
65
76
[ UnityTest ]
66
- public IEnumerator AnimationTriggerReset ( [ Values ( true , false ) ] bool asHash )
77
+ public IEnumerator AnimationTriggerReset ( [ Values ( true , false ) ] bool asHash , [ Values ( true , false ) ] bool hostMode )
67
78
{
79
+ yield return Init ( hostMode ) ;
80
+
68
81
// We have "UnboundTrigger" purposely not bound to any animations so we can test resetting.
69
82
// If we used a trigger that was bound to a transition, then the trigger would reset as soon as the
70
83
// transition happens. This way it will stay stuck on
@@ -114,9 +127,12 @@ public IEnumerator AnimationTriggerReset([Values(true, false)] bool asHash)
114
127
Assert . False ( s_GloabalTimeOutHelper . TimedOut , "Timed out on client reset check" ) ;
115
128
}
116
129
130
+
117
131
[ UnityTest ]
118
- public IEnumerator AnimationStateSyncTest ( )
132
+ public IEnumerator AnimationStateSyncTest ( [ Values ( true , false ) ] bool hostMode )
119
133
{
134
+ yield return Init ( hostMode ) ;
135
+
120
136
// check that we have started in the default state
121
137
Assert . True ( m_PlayerOnServerAnimator . GetCurrentAnimatorStateInfo ( 0 ) . IsName ( "DefaultState" ) ) ;
122
138
Assert . True ( m_PlayerOnClientAnimator . GetCurrentAnimatorStateInfo ( 0 ) . IsName ( "DefaultState" ) ) ;
@@ -137,8 +153,10 @@ public IEnumerator AnimationStateSyncTest()
137
153
}
138
154
139
155
[ UnityTest ]
140
- public IEnumerator AnimationStateSyncTriggerTest ( [ Values ( true , false ) ] bool asHash )
156
+ public IEnumerator AnimationStateSyncTriggerTest ( [ Values ( true , false ) ] bool asHash , [ Values ( true , false ) ] bool hostMode )
141
157
{
158
+ yield return Init ( hostMode ) ;
159
+
142
160
string triggerString = "TestTrigger" ;
143
161
int triggerHash = Animator . StringToHash ( triggerString ) ;
144
162
@@ -172,8 +190,9 @@ public IEnumerator AnimationStateSyncTriggerTest([Values(true, false)] bool asHa
172
190
}
173
191
174
192
[ UnityTest ]
175
- public IEnumerator AnimationStateSyncTestWithOverride ( )
193
+ public IEnumerator AnimationStateSyncTestWithOverride ( [ Values ( true , false ) ] bool hostMode )
176
194
{
195
+ yield return Init ( hostMode ) ;
177
196
// set up the animation override controller
178
197
var overrideController = Resources . Load ( "TestAnimatorOverrideController" ) as AnimatorOverrideController ;
179
198
m_PlayerOnServer . GetComponent < Animator > ( ) . runtimeAnimatorController = overrideController ;
0 commit comments