SpawnObjectBeforeConnect.cs
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections;
using NUnit.Framework;
using UnityEngine.TestTools;
using UnityEngine;
using UnityEngine.Networking;
#pragma warning disable 618
public class SpawnObjectBeforeConnect : SpawningTestBase
{
bool isDone;
[UnityTest]
public IEnumerator SpawnObjectBeforeConnectTest()
{
NetworkClient.ShutdownAll();
NetworkServer.Reset();
SetupPrefabs();
StartServer();
GameObject obj = (GameObject)Instantiate(rockPrefab, Vector3.zero, Quaternion.identity);
NetworkServer.Spawn(obj);
StartClientAndConnect();
while (!isDone)
{
yield return null;
}
ClientScene.DestroyAllClientObjects();
yield return null;
NetworkServer.Destroy(obj);
NetworkServer.Destroy(playerObj);
}
public override void OnServerReady(GameObject player)
{
Assert.AreEqual(2, numStartServer);
}
public override void OnClientReady(short playerId)
{
Assert.AreEqual(2, numStartClient);
isDone = true;
}
}
#pragma warning restore 618