- Home /
The question is answered, right answer was accepted
Master Server GUI not showing up [Errors finally coming up in console]
im trying to connect to the master server and the GUI to look for a server is not showing up. Im calling a function from within the GUI function so it should work.
if (GUI.Button(new Rect(Screen.width / 2 - 64, Screen.height / 2 + 144, 132, 32),"World-Wide Connect")) {
MastServ();
menu_WWconnect = true;
play_menu = false;
}
if (menu_WWconnect) {
ServerWWConnect ();
}
void ServerWWConnect ()
{
playerName = GUI.TextField(new Rect(Screen.width / 2 - 64, Screen.height / 2 - 47, 128, 24), playerName, 18);
HostData[] data = MasterServer.PollHostList();
foreach(HostData element in data) {
GUILayout.BeginHorizontal();
string name= element.gameName + " -- " + element.connectedPlayers + " / " + element.playerLimit;
GUILayout.Label(name);
GUILayout.Space(5);
string hostInfo;
hostInfo = "[";
foreach(string host in element.ip)
hostInfo = hostInfo + host + ":" + element.port + " ";
hostInfo = hostInfo + "]";
GUILayout.Label(hostInfo);
GUILayout.Space(5);
GUILayout.Label(element.comment);
GUILayout.Space(5);
GUILayout.FlexibleSpace();
if (GUILayout.Button("Join")) {
Network.Connect(element);
PlayerPrefs.SetString("Player_Name", playerName);
}
GUILayout.EndHorizontal();
}
if (GUI.Button(new Rect(32, Screen.height - 64, 128, 32),"Back")) {
menu_WWconnect = false;
play_menu = true;
}
}
I think its in the last part
All GUI code must be inside of void OnGUI(). $$anonymous$$ost of your gui code here is inside your ServerConnect method.
it works with other stuff, for me. And by that I mean, calling an external function from outside OnGUI..
using UnityEngine;
using System;
using System.Collections;
public class Example : $$anonymous$$onoBehaviour
{
void Update()
{
NotInGUI();
}
//Will not work.
void NotInGUI()
{
GUILayout.Label("Outside of GUI Function");
}
//Will work.
void OnGUI()
{
GUILayout.Label("Inside GUI Function");
}
}
putting it back inside OnGUI did not do anything.
nono that comes up fine! its not when I create a server.. its when i look for that (connecting)
as you can see, creating it works finw.
now, if another player clicks browse servers...
now, in this final picture, the list of servers (the one we just made), should show up in a horiz layout, with the name, and a button saying "Join" but it doesnt. that is the issue.
Answer by thornekey · May 06, 2014 at 01:08 PM
Solved it!
In the end, the issue was simple.
I had this:
MasterServer.RegisterHost(myGameType,"RobotCountDown", myGameDesc);
myGameType was where the game name should be. I got them around the wrong way!
lol silly
for posting your solution! I re-accepted your answer so you could get a bit of karma ;)
thanks :) It was good to figure it out myself. Only took 2 days ahah
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Client can't spawn GameObject's 0 Answers
[Command] Attribute Returning Warnings and Errors 0 Answers
Unity3d Csharp Networking Error 3 Answers
Distribute terrain in zones 3 Answers