mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Update HostSetup.cs
adding virtual methods for test setup
This commit is contained in:
parent
7bcf957c23
commit
3fcc7415b4
@ -1,5 +1,4 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using NUnit.Framework;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.TestTools;
|
using UnityEngine.TestTools;
|
||||||
|
|
||||||
@ -14,6 +13,11 @@ public class HostSetup
|
|||||||
protected GameObject playerGO;
|
protected GameObject playerGO;
|
||||||
protected NetworkIdentity identity;
|
protected NetworkIdentity identity;
|
||||||
|
|
||||||
|
protected virtual bool AutoAddPlayer => true;
|
||||||
|
|
||||||
|
protected virtual void afterStartHost() { }
|
||||||
|
protected virtual void beforeStopHost() { }
|
||||||
|
|
||||||
[UnitySetUp]
|
[UnitySetUp]
|
||||||
public IEnumerator SetupHost()
|
public IEnumerator SetupHost()
|
||||||
{
|
{
|
||||||
@ -28,15 +32,30 @@ public IEnumerator SetupHost()
|
|||||||
|
|
||||||
manager.playerPrefab = playerGO;
|
manager.playerPrefab = playerGO;
|
||||||
manager.autoStartServerBuild = false;
|
manager.autoStartServerBuild = false;
|
||||||
|
manager.autoCreatePlayer = AutoAddPlayer;
|
||||||
|
|
||||||
|
if (Application.isBatchMode)
|
||||||
|
{
|
||||||
|
Application.targetFrameRate = 60;
|
||||||
|
}
|
||||||
|
|
||||||
yield return null;
|
yield return null;
|
||||||
|
|
||||||
manager.StartHost();
|
manager.StartHost();
|
||||||
|
|
||||||
|
yield return null;
|
||||||
|
|
||||||
|
afterStartHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TearDown]
|
|
||||||
public void ShutdownHost()
|
[UnityTearDown]
|
||||||
|
public IEnumerator ShutdownHost()
|
||||||
{
|
{
|
||||||
|
beforeStopHost();
|
||||||
|
|
||||||
|
yield return null;
|
||||||
|
|
||||||
Object.DestroyImmediate(playerGO);
|
Object.DestroyImmediate(playerGO);
|
||||||
manager.StopHost();
|
manager.StopHost();
|
||||||
Object.DestroyImmediate(networkManagerGo);
|
Object.DestroyImmediate(networkManagerGo);
|
||||||
|
Loading…
Reference in New Issue
Block a user