UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a room in an online game"
public class HostGameLocal : MonoBehaviour { [SerializeField] private uint roomSize = 6; private string roomName; private NetworkManager networkManager; void Start() { networkManager = NetworkManager.singleton; if (networkManager.matchMaker == null) { networkManager.StartMatchMaker (); } } public void SetRoomName(string _name) { roomName = _name; } public void CreateRoom() { if (roomName != null && roomName != "") { Debug.Log ("Creating room: " + roomName + " with room for " + roomSize + " players."); networkManager.matchMaker.CreateMatch(roomName, roomSize, true, "", "", "", 0, 0, networkManager.OnMatchCreate); } } }