Hello,
So I’m adding MP to my game following a Unity tutorial, and I’m having a problem
with switch statements.
here’s the code:
void TestConnection (){
// Start/Poll the connection test, report the results in a label and react to the results accordingly
natCapable = Network.TestConnection();
switch (natCapable) {
case ConnectionTesterStatus.Error:
testMessage = "Problem determining NAT capabilities";
doneTesting = true;
break;
case ConnectionTesterStatus.Undetermined:
testMessage = "Undetermined NAT capabilities";
doneTesting = false;
break;
case ConnectionTesterStatus.PrivateIPNoNATPunchthrough:
testMessage = "Cannot do NAT punchthrough, filtering NAT enabled hosts for client connections,"
+" local LAN games only.";
filterNATHosts = true;
Network.useNat = true;
doneTesting = true;
break;
case ConnectionTesterStatus.PrivateIPHasNATPunchThrough:
if (probingPublicIP)
testMessage = "Non-connectable public IP address (port "+ serverPort +" blocked),"
+" NAT punchthrough can circumvent the firewall.";
else
testMessage = "NAT punchthrough capable. Enabling NAT punchthrough functionality.";
// NAT functionality is enabled in case a server is started,
// clients should enable this based on if the host requires it
Network.useNat = true;
doneTesting = true;
break;
case ConnectionTesterStatus.PublicIPIsConnectable:
testMessage = "Directly connectable public IP address.";
Network.useNat = false;
doneTesting = true;
break;
// This case is a bit special as we now need to check if we can
// use the blocking by using NAT punchthrough
case ConnectionTesterStatus.PublicIPPortBlocked:
testMessage = "Non-connectble public IP address (port " + serverPort +" blocked),"
+" running a server is impossible.";
Network.useNat = false;
// If no NAT punchthrough test has been performed on this public IP, force a test
if (!probingPublicIP)
{
Debug.Log("Testing if firewall can be circumnvented");
natCapable = Network.TestConnectionNAT();
probingPublicIP = true;
timer = Time.time + 10;
}
// NAT punchthrough test was performed but we still get blocked
else if (Time.time > timer)
{
probingPublicIP = false; // reset
Network.useNat = true;
doneTesting = true;
}
break;
case ConnectionTesterStatus.PublicIPNoServerStarted:
testMessage = "Public IP address but server not initialized,"
+"it must be started to check server accessibility. Restart connection test when ready.";
break;
default:
testMessage = "Error in test routine, got " + natCapable;
}
}
and from there I get this error:
“Control cannot fall through from one case label to another.”
Any help?