Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Unity crash when i use MasterServer.RegisterHost script

$
0
0
Now i learning how to make multiplayer game and i have problem when i use "MasterServer.RegisterHost(gameName, name, des)" Unity crash. Code (read comments): #pragma strict var gameName : String = "Kmcdiklomnd_Learning_Multiplayer"; private var btnX : float; private var btnY : float; private var btnW : float; private var btnH : float; function Start(){ btnX = Screen.width * 0.05; btnY = Screen.width * 0.05; btnW = Screen.width * 0.1; btnH = Screen.width * 0.1; } function startServer(){ Network.InitializeServer(4, 25001, !Network.HavePublicAddress); // I use yield WaitForSeconds(2); to test then Unity crash. yield WaitForSeconds(2); // If i delete this \/ line of code everything works, so this line crash Unity MasterServer.RegisterHost(gameName, "Learning Multiplayer Game Name", "This is learning game"); } //Messages function OnServerInitialized(){ Debug.Log("Server initialized!"); } // This function dont work because Unity crash before it start function OnMasterServerEvent(mse : MasterServerEvent){ if(mse == MasterServerEvent.RegistrationSucceeded){ Debug.Log("Registered Server!"); } } function OnGUI () { if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Start Server")){ Debug.Log("Starting Server"); startServer(); } if(GUI.Button(Rect(btnX, btnY * 1.2 + btnH, btnW, btnH), "Refresh Host")){ Debug.Log("Refreshing"); } } So did anyone know how to fix it?

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>