-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuGUIScript.cs
executable file
·84 lines (72 loc) · 2.41 KB
/
MenuGUIScript.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using UnityEngine;
using System.Collections;
public class MenuGUIScript : MonoBehaviour
{
bool serverStarted = false;
//MasterServer master;
// Use this for initialization
int timer = 0;
void Start()
{
//master = new MasterServer();
//MasterServer.ipAddress = "192.168.1.43";
//MasterServer.port = 23466;
//MasterServer.
//MasterServer.updateRate = 100;
//MasterServer.RequestHostList("regular");
}
void Awake()
{
//MasterServer.RequestHostList("regular");
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
}
void OnGUI()
{
if (!serverStarted)
{
if (GUI.Button(new Rect(30, 30, 150, 50), "Start a Server"))
{
serverStarted = true;
Network.InitializeServer(32, 25002, !Network.HavePublicAddress());
//MasterServer.RegisterHost("regular", "nick", "test");
Application.LoadLevel(1);
}
}
if (GUI.Button(new Rect(30, 80, 150, 50), "Join Local Server"))
{
Network.Connect("127.0.0.1", 25002);
Application.LoadLevel(1);
}
//HostData[] data = MasterServer.PollHostList();
//// Go through all the hosts in the host list
//foreach (HostData element in data)
//{
// GUILayout.BeginHorizontal();
// var 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("Connect"))
// {
// // Connect to HostData struct, internally the correct method is used (GUID when using NAT).
// Network.Connect(element);
// }
// GUILayout.EndHorizontal();
//}
}
}