- Home /
Please help! In function Create room my button is not working, line 64 I think
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections.Generic;
 using UnityEngine.Networking;
 using UnityEngine.Networking.Match;
 
 public class HostGame : MonoBehaviour {
 
     List<GameObject> roomList = new List<GameObject>();
 
     [SerializeField]
     private uint MaxPlayers = 20;
 
     private string RoomName;
 
     public InputField input;
 
     [SerializeField]
     private Transform roomListParent;
 
     [SerializeField]
     private GameObject roomListItemPrefab;
 
     [SerializeField]
     private Text Status; 
 
     public GameObject character;
 
     public NetworkManager networkManager;
 
     public GameObject ObjectToDisable1;
     public GameObject ObjectToDisable2;
     public GameObject ObjectToDisable3;
     public GameObject ObjectToEnable1;
     public GameObject ObjectToEnable2;
     public GameObject ObjectToEnable3;
 
     void Start() {
         networkManager = NetworkManager.singleton;
         if (networkManager.matchMaker == null) {
             networkManager.StartMatchMaker ();
         }
         networkManager.playerPrefab = character;
         RefreshRoomList ();
     }
     void update() {
         RoomName = input.ToString();
     }
 
     public void UIon() {
         ObjectToDisable1.SetActive(false);
         ObjectToDisable2.SetActive(false);
         ObjectToDisable3.SetActive(false);
         ObjectToEnable1.SetActive(false);
         ObjectToEnable2.SetActive(false);
         ObjectToEnable3.SetActive (true);
     }
 
     public void RefreshRoomList(){
         clearRoomList ();
         networkManager.matchMaker.ListMatches(0, 20, "", false, 3, 3, OnMatchList);
         Status.text = "loading";
     }
 
 
     public void CreateRoom() {
         if (RoomName != null && RoomName != ""){
             Debug.Log("Creating room: " + RoomName + " with room size: " + MaxPlayers);
             networkManager.matchMaker.CreateMatch(RoomName, MaxPlayers, true, "", "", "", 0, 0, networkManager.OnMatchCreate);
         }
     }
     public void JoinGame(){
         ObjectToDisable1.SetActive(false);
         ObjectToDisable2.SetActive(false);
         ObjectToDisable3.SetActive(false);
         ObjectToEnable1.SetActive(true);
         ObjectToEnable2.SetActive(true);
     }
     public void OnMatchList (bool Sucess, string Extendedinfo, List <MatchInfoSnapshot> matches){
         Status.text = "";
         if (matches == null) {
             Status.text = "Couldn't Find any Rooms, Try Refreshing";
             return;
         }
         foreach (MatchInfoSnapshot match in matches) {
                 GameObject _roomListItemGO = Instantiate(roomListItemPrefab);
                 _roomListItemGO.transform.SetParent(roomListParent);
                 roomList.Add (_roomListItemGO);
             }
         if (roomList.Count == 0) {
             Status.text = "Sorry, no Rooms now.";
         }
     }
 
     public void clearRoomList(){
         for (int i = 0; i < roomList.Count; i++) {
             Destroy (roomList [i]);
         }
         roomList.Clear();
     }
 }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
How do I connect a client to a server? 2 Answers
Asynchronous Game server 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                