Has anyone else encountered an issue where buttons stop registering a press after a client fails to connect to a server?
I believe the problem could be down to my computer configuration. I have had a friend test the script below on a Mac (Same unity version) and it did not have the same problem.
I am currently using Unity 3.5.7f6 on windows 8.
To reproduce the problem (Or not) do the following
- Create a new unity project
- add an empty game node
- create a new c# script
- copy and paste the script below
- attach the script to our empty game node
- Run…
You should be presented with a button labelled “Test Button Start”. Press this. You will then get a “Connecting…” message. This is attempting to connect a client. This will time out after about 10 seconds causing an OnFailedToConnect() callback. You will then be presented with a second button called “Test Button After”. On my computer this button will not register a button press. If it does work for you then you should finally be presented with a “Finished” label.
Any feedback or information would be greatly appreciated.
using UnityEngine;
using System.Collections;
public class Flow : MonoBehaviour
{
enum states
{
TestButtonStart,
Connecting,
TestButtonafter,
Finish
}
private states m_State;
// Use this for initialization
void Start ()
{
m_State = states.TestButtonStart;
}
void OnGUI()
{
switch(m_State)
{
case states.TestButtonStart:
if(GUILayout.Button(“Test Button Start”))
{
m_State = states.Connecting;
Network.Connect(“127.0.0.1”, 25000);
}
break;
case states.Connecting:
GUILayout.Label(“Connecting…”);
break;
case states.TestButtonafter:
if(GUILayout.Button(“Test Button After”))
{
m_State = states.Finish;
}
break;
case states.Finish:
GUILayout.Label(“Finished”);
break;
default:
break;
}
}
void OnFailedToConnect(NetworkConnectionError error)
{
if(m_State == states.Connecting)
{
m_State = states.TestButtonafter;
}
}
}