- Home /
Question by
DLGScript · Sep 23, 2012 at 09:15 AM ·
c#javascript
Help| Convert a javascript to C#
i got this script from unity menual:
function Awake() {
MasterServer.RequestHostList("MadBubbleSmashGame");
}
function OnGUI() {
var data : HostData[] = MasterServer.PollHostList();
// Go through all the hosts in the host list
for (var element in data)
{
GUILayout.BeginHorizontal();
var name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit;
GUILayout.Label(name);
GUILayout.Space(5);
var hostInfo;
hostInfo = "[";
for (var host in element.ip)
hostInfo = hostInfo + host + ":" + element.port + " ";
hostInfo = hostInfo + "]";
GUILayout.Label(hostInfo);
GUILayout.Space(5);
GUILayout.Label(element.comment);
GUILayout.Space(5);
GUILayout.FlexibleSpace();
if (GUILayout.Button("Connect"))
{
// Connect to HostData struct, internally the correct method is used (GUID when using NAT).
Network.Connect(element);
}
GUILayout.EndHorizontal();
}
}
PLEASE CONVERT IT TO C#! !! :D
Comment
Where in the unity manual did you find this? There should be a tab right next to the script that allows you to switch from Javascript to C#.
i know but i didn't find it. there is no button of changing.
Answer by dscroggi · Sep 26, 2012 at 07:36 AM
http://files.m2h.nl//js_to_c.php
Courtesy of the guys at M2H game studio in the Netherlands.
Your answer
Follow this Question
Related Questions
CS0116 "A namespace can only contain type and namespace declarations" 1 Answer
Randomly Generated Objects 1 Answer
What Am I Doing Wrong? Variable Names 3 Answers
Objectives based on object appear. 2 Answers
Setting Scroll View Width GUILayout 1 Answer