diff --git a/Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity b/Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity index c35f54574..05e01d79c 100644 --- a/Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity +++ b/Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity @@ -1530,13 +1530,14 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 821201137} - - component: {fileID: 821201136} - component: {fileID: 821201135} - - component: {fileID: 821201138} - component: {fileID: 821201142} + - component: {fileID: 821201138} + - component: {fileID: 821201136} - component: {fileID: 821201140} - component: {fileID: 821201139} - component: {fileID: 821201141} + - component: {fileID: 821201143} m_Layer: 0 m_Name: NetworkManager m_TagString: Untagged @@ -1570,10 +1571,10 @@ MonoBehaviour: playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3} autoCreatePlayer: 1 playerSpawnMethod: 0 - spawnPrefabs: - - {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3} - - {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3} + spawnPrefabs: [] timeInterpolationGui: 1 + botPrefab: {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3} + npcPrefab: {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3} --- !u!114 &821201136 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1708,6 +1709,18 @@ MonoBehaviour: debugLog: 0 statisticsGUI: 0 statisticsLog: 0 +--- !u!114 &821201143 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 821201133} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bc5b42cbfc38b1c4d86fd25905b19e29, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &920376379 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity b/Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity index 089166d58..5f1528108 100644 --- a/Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity +++ b/Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity @@ -1530,10 +1530,10 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 821201137} - - component: {fileID: 821201136} - component: {fileID: 821201135} - - component: {fileID: 821201138} - component: {fileID: 821201134} + - component: {fileID: 821201138} + - component: {fileID: 821201136} - component: {fileID: 821201140} - component: {fileID: 821201139} - component: {fileID: 821201141} @@ -1557,7 +1557,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0110f245bfcfc7d459681f7bd9ebc590, type: 3} m_Name: m_EditorClassIdentifier: - port: 7777 + port: 27777 maxMessageSize: 16384 handshakeMaxSize: 3000 noDelay: 1 @@ -1586,8 +1586,8 @@ MonoBehaviour: m_EditorClassIdentifier: dontDestroyOnLoad: 1 runInBackground: 1 - autoStartServerBuild: 1 - autoConnectClientBuild: 0 + autoStartServerBuild: 0 + autoConnectClientBuild: 1 sendRate: 30 offlineScene: Assets/Mirror/Examples/TestNT/Scenes/OfflineWeb.unity onlineScene: Assets/Mirror/Examples/TestNT/Scenes/Online.unity @@ -1598,10 +1598,10 @@ MonoBehaviour: playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3} autoCreatePlayer: 1 playerSpawnMethod: 0 - spawnPrefabs: - - {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3} - - {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3} + spawnPrefabs: [] timeInterpolationGui: 1 + botPrefab: {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3} + npcPrefab: {fileID: 9078678990242496461, guid: 41855c7cf63a3dc45ac8a93b4e2ecd54, type: 3} --- !u!114 &821201136 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs b/Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs index 41b89393f..1fb0b7427 100644 --- a/Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs +++ b/Assets/Mirror/Examples/TestNT/Scripts/NPCHandler.cs @@ -36,7 +36,7 @@ void Update() void CmdSpawnNPC() { //Vector3 spawnPos = transform.position + Vector3.forward; - GameObject npc = Instantiate(NetworkManager.singleton.spawnPrefabs[0]); + GameObject npc = Instantiate(TestNTNetworkManager.singleton.npcPrefab); npc.GetComponent().playerName = "NPC"; npc.GetComponent().enabled = true; npc.GetComponent().enabled = true; diff --git a/Assets/Mirror/Examples/TestNT/Scripts/TestNTNetworkManager.cs b/Assets/Mirror/Examples/TestNT/Scripts/TestNTNetworkManager.cs index a97ccf897..9cb463719 100644 --- a/Assets/Mirror/Examples/TestNT/Scripts/TestNTNetworkManager.cs +++ b/Assets/Mirror/Examples/TestNT/Scripts/TestNTNetworkManager.cs @@ -13,6 +13,9 @@ public class TestNTNetworkManager : NetworkManager // have to cast to this type everywhere. public static new TestNTNetworkManager singleton { get; private set; } + public GameObject botPrefab; + public GameObject npcPrefab; + /// /// Runs on both Server and Client /// Networking is NOT initialized when this fires @@ -46,15 +49,13 @@ public void OnSelectServer(int server) #region Unity Callbacks - /// - /// Runs on both Server and Client - /// Networking is NOT initialized when this fires - /// +#if UNITY_SERVER public override void Start() { -#if UNITY_SERVER if (autoStartServerBuild) { + // set default sendRate, then let CmdLineArgs override + Application.targetFrameRate = 30; ProcessCmdLineArgs(); ((SimpleWebTransport)Transport.active).sslEnabled = false; ((SimpleWebTransport)Transport.active).clientUseWss = false; @@ -64,16 +65,16 @@ public override void Start() // only start server or client, never both else if (autoConnectClientBuild) { + // set default sendRate, then let CmdLineArgs override + Application.targetFrameRate = 60; ProcessCmdLineArgs(); ((TestNTNetworkAuthenticator)authenticator).SetPlayername($"Bot[{sendRate}] ", true); ((SimpleWebTransport)Transport.active).sslEnabled = true; ((SimpleWebTransport)Transport.active).clientUseWss = true; StartClient(); } -#endif } -#if UNITY_SERVER void ProcessCmdLineArgs() { foreach (string arg in Environment.GetCommandLineArgs()) @@ -187,7 +188,7 @@ public override void OnServerAddPlayer(NetworkConnectionToClient conn) GameObject player; if (authData.isBot) - player = Instantiate(spawnPrefabs[1]); + player = Instantiate(botPrefab); else player = Instantiate(playerPrefab); @@ -287,7 +288,11 @@ public override void OnStartServer() /// /// This is invoked when the client is started. /// - public override void OnStartClient() { } + public override void OnStartClient() + { + NetworkClient.RegisterPrefab(botPrefab); + NetworkClient.RegisterPrefab(npcPrefab); + } /// /// This is called when a host is stopped.