Advertisement
chrisall76

Untitled

Nov 1st, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Networking;
  3. using UnityEngine.Networking.Types;
  4. using UnityEngine.Networking.Match;
  5. using UnityEngine.UI;
  6. using System.Collections;
  7.  
  8. public class CreateServer : MonoBehaviour {
  9.  
  10.     public InputField ServerName;
  11.     public InputField MaxPlayers;
  12.     [HideInInspector]
  13.     public string ErrorDialog;
  14.     [HideInInspector]
  15.     public bool connectFailed = false;
  16.     public static readonly string SceneNameGame = "Test Scene";
  17.  
  18.     public void CreateAServer() {
  19.         //Setup the server's variables
  20.         int PCount = int.Parse(MaxPlayers.text);
  21.         CreateMatchRequest create = new CreateMatchRequest();
  22.         create.name = ServerName.text;
  23.         create.size = (uint)int.Parse(MaxPlayers.text);
  24.         create.advertise = true;
  25.         create.password = "";
  26.  
  27.         //Start the match
  28.         ENetManager.Current.matchMaker.CreateMatch(create, ENetManager.Current.OnMatchCreate);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement