diff --git a/Assets/Mirror/Tests/Common/MirrorTest.cs b/Assets/Mirror/Tests/Common/MirrorTest.cs index 9e1320fdd..04981418c 100644 --- a/Assets/Mirror/Tests/Common/MirrorTest.cs +++ b/Assets/Mirror/Tests/Common/MirrorTest.cs @@ -138,6 +138,21 @@ protected void CreateNetworked(out GameObject go, out NetworkIdentity i instantiated.Add(go); } + // create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN + // => ownerConnection can be NetworkServer.localConnection if needed. + protected void CreateNetworkedAndSpawn(out GameObject go, out NetworkIdentity identity, NetworkConnection ownerConnection = null) + { + // server & client need to be active before spawning + Debug.Assert(NetworkClient.active, "NetworkClient needs to be active before spawning."); + Debug.Assert(NetworkServer.active, "NetworkServer needs to be active before spawning."); + + CreateNetworked(out go, out identity); + + // spawn + NetworkServer.Spawn(go, ownerConnection); + ProcessMessages(); + } + // create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN // => ownerConnection can be NetworkServer.localConnection if needed. protected void CreateNetworkedAndSpawn(out GameObject go, out NetworkIdentity identity, out T component, NetworkConnection ownerConnection = null)