public void Setup() { // Create, instantiate, and host Assert.IsTrue(NetworkManagerHelper.StartNetworkManager(out _)); }
public void Setup() { //Create, instantiate, and host NetworkManagerHelper.StartNetworkManager(out _); }
public void Setup() { //Create, instantiate, and host NetworkManagerHelper.StartNetworkManager(out _, NetworkManagerHelper.NetworkManagerOperatingMode.None); }
public void NetworkPrefabHandlerClass() { Assert.IsTrue(NetworkManagerHelper.StartNetworkManager(out _)); var testPrefabObjectName = "NetworkPrefabHandlerTestObject"; Guid baseObjectID = NetworkManagerHelper.AddGameNetworkObject(testPrefabObjectName); NetworkObject baseObject = NetworkManagerHelper.InstantiatedNetworkObjects[baseObjectID]; var networkPrefabHandler = new NetworkPrefabHandler(); var networkPrefaInstanceHandler = new NetworkPrefaInstanceHandler(baseObject); var prefabPosition = new Vector3(1.0f, 5.0f, 3.0f); var prefabRotation = new Quaternion(1.0f, 0.5f, 0.4f, 0.1f); //Register via GameObject var gameObjectRegistered = networkPrefabHandler.AddHandler(baseObject.gameObject, networkPrefaInstanceHandler); //Test result of registering via GameObject reference Assert.True(gameObjectRegistered); var spawnedObject = networkPrefabHandler.HandleNetworkPrefabSpawn(baseObject.GlobalObjectIdHash, 0, prefabPosition, prefabRotation); //Test that something was instantiated Assert.NotNull(spawnedObject); //Test that this is indeed an instance of our original object Assert.True(spawnedObject.name.Contains(testPrefabObjectName)); //Test for position and rotation Assert.True(prefabPosition == spawnedObject.transform.position); Assert.True(prefabRotation == spawnedObject.transform.rotation); networkPrefabHandler.HandleNetworkPrefabDestroy(spawnedObject); //Destroy our prefab instance networkPrefabHandler.RemoveHandler(baseObject); //Remove our handler //Register via NetworkObject gameObjectRegistered = networkPrefabHandler.AddHandler(baseObject, networkPrefaInstanceHandler); //Test result of registering via NetworkObject reference Assert.True(gameObjectRegistered); //Change it up prefabPosition = new Vector3(2.0f, 1.0f, 5.0f); prefabRotation = new Quaternion(4.0f, 1.5f, 5.4f, 5.1f); spawnedObject = networkPrefabHandler.HandleNetworkPrefabSpawn(baseObject.GlobalObjectIdHash, 0, prefabPosition, prefabRotation); //Test that something was instantiated Assert.NotNull(spawnedObject); //Test that this is indeed an instance of our original object Assert.True(spawnedObject.name.Contains(testPrefabObjectName)); //Test for position and rotation Assert.True(prefabPosition == spawnedObject.transform.position); Assert.True(prefabRotation == spawnedObject.transform.rotation); networkPrefabHandler.HandleNetworkPrefabDestroy(spawnedObject); //Destroy our prefab instance networkPrefabHandler.RemoveHandler(baseObject); //Remove our handler //Register via GlobalObjectIdHash gameObjectRegistered = networkPrefabHandler.AddHandler(baseObject.GlobalObjectIdHash, networkPrefaInstanceHandler); //Test result of registering via GlobalObjectIdHash reference Assert.True(gameObjectRegistered); //Change it up prefabPosition = new Vector3(6.0f, 4.0f, 1.0f); prefabRotation = new Quaternion(3f, 2f, 4f, 1f); spawnedObject = networkPrefabHandler.HandleNetworkPrefabSpawn(baseObject.GlobalObjectIdHash, 0, prefabPosition, prefabRotation); //Test that something was instantiated Assert.NotNull(spawnedObject); //Test that this is indeed an instance of our original object Assert.True(spawnedObject.name.Contains(testPrefabObjectName)); //Test for position and rotation Assert.True(prefabPosition == spawnedObject.transform.position); Assert.True(prefabRotation == spawnedObject.transform.rotation); networkPrefabHandler.HandleNetworkPrefabDestroy(spawnedObject); //Destroy our prefab instance networkPrefabHandler.RemoveHandler(baseObject); //Remove our handler Assert.False(networkPrefaInstanceHandler.StillHasInstances()); }
public void Setup() { // Create, instantiate, and host Assert.IsTrue(NetworkManagerHelper.StartNetworkManager(out _, NetworkManagerHelper.NetworkManagerOperatingMode.None)); m_ValidationToken = Guid.NewGuid(); }