void Start()
{
// Determine if a port argument was provide, signify a server instance
string portCheck = "+port:";
string[] args = System.Environment.GetCommandLineArgs();
foreach (string arg in args)
{
if (arg.Contains(portCheck))
{
// Port argument found, try to retrieve the provided port number
string strPortNum = arg.Substring(arg.IndexOf(portCheck) + portCheck.Length);
int portNum;
if (int.TryParse(strPortNum, out portNum))
{
// Instantiate temporary object to pass port number to network manager
GameObject serverInfo = GameObject.Instantiate(serverSetupInfoPrefab);
serverInfo.GetComponent<ServerSetupInfo>().portNumber = portNum;
// Load the scene for the server
Application.LoadLevel(serverScene);
}
}
}
// Otherwise, load the scene for the client
Application.LoadLevel(clientScene);
}
}