Before you read and perhaps miss it, Thanks in advance :).
Gday, I was wondering how to let a user input their own name and select a scene for a server they can create?
I have a few scenes to pick from, I just dont know how to implement it correct.
These are the lines I would like the user to select.
(room name would be a scene)
var gameNameRoom : String = "room1_test";
var gameComment : String = "testing here";
(gameNameRoom would be a scene the user can select.)
something like
var gameNameRoom : String [];
and
hostData = MasterServer.PollHostList ,gameNameRoom ();
I have this, sorry about the mess.
var gameNameRoom : String = "room1_test";
var gameComment : String = "testing here";
var startserveranim : GameObject;
var startserveranim2 : GameObject;
var ServerStart : GUITexture;
var refreshServerlist : GUITexture;
var native_width : float = 1280;
var native_height : float = 720;
var customskin : GUISkin;
private var refreshing : boolean ;
private var hostData : HostData [];
private var gameName : String = "Test Server";
function StartServer (){
Network.InitializeServer (10, 25001, !Network.HavePublicAddress);
MasterServer.RegisterHost(gameName, gameNameRoom , gameComment);
}
function RefreshHostList (){
MasterServer.RequestHostList(gameName);
refreshing = true;
MasterServer.PollHostList();
}
function OnServerInitialized () {
Debug.Log ("Server Initialized");
}
function OnMasterServerEvent (mse:MasterServerEvent){
if (mse == MasterServerEvent.RegistrationSucceeded){
Debug.Log ("Registred Server");
}
}
function Update(){
if(MasterServer.PollHostList().Length > 0){
refreshing = false;
Debug.Log (MasterServer.PollHostList().Length);
hostData = MasterServer.PollHostList();
}
for (var touch : Touch in Input.touches)
{
if (touch.phase == TouchPhase.Ended && ServerStart.HitTest (touch.position)) {
startserveranim.animation.Play();
startserveranim2.animation.Play();
StartServer ();
}
if (touch.phase == TouchPhase.Began && refreshServerlist.HitTest (touch.position)) {
RefreshHostList ();
}
}
}
function OnGUI (){
GUI.skin = customskin;
var rx : float = Screen.width / native_width;
var ry : float = Screen.height / native_height;
GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (rx, ry, 1));
if(hostData && !refreshing ){
GUI.skin = customskin;
for (var i:int = 0; i<hostData.length; i++){
if( GUI.Button(Rect(110, 155, 300, 100),hostData *.gameName)){*
if (!Network.isServer && !Network.isClient){
Network.Connect(hostData*);*
}
}
}
}
}