I am making a game and there needs to be a way to set up a server and join a server without so much scripting. I hope unity can do something like that like with 4.6 and the gui system. Or is there a JavaScript tutorial out there. any scripts or links would be grate. This thred will be a place to make your scripts and help thousands of noobs like my self.
Hosting Code (CSharp): void Host(int players, int port, string room, string comment) { Network.InitializeServer(players, port, !Network.HavePublicAddress()); MasterServer.RegisterHost("Main game name", room, comment); } Joining Code (CSharp): void Update() { HostData[] hostList = MasterServer.PollHostList(); if (hostList.Length > 0) { this.buttons.ForEach(button => Destroy(button.gameObject)); this.buttons = new List<Button>(); foreach (HostData hostData in hostList) { HostData _hostData = hostData; // For onClick listener delegate Button button = Instantiate<Button>(this.buttonPrefab); button.transform.SetParent(this.serverListTransform); button.GetComponentInChildren<Text>().text = "Join " + hostData.gameName; button.onClick.AddListener(() => Network.Connect(_hostData)); this.buttons.Add(button); } MasterServer.ClearHostList(); } } Refreshing Code (CSharp): void Refresh() { MasterServer.RequestHostList("Main game name"); } Add a layout group (probably vertical) to this.serverListTransform, and add Host and Refresh buttons that call Host() and Refresh(), respectively.