public static ORTCPClient CreateClientInstance(string name, TcpClient tcpClient, TCPMultiServer serverDelegate) { GameObject go = new GameObject(name); ORTCPClient client = go.AddComponent <ORTCPClient>(); client.SetTcpClient(tcpClient); client.serverDelegate = serverDelegate; client.verbose = false; return(client); }
/// <summary> /// Awake assigns the static singleton. /// Because reloading a scene will cause Unity to duplicate objects, the static /// exists boolean will destroy any duplicate objects so there is only ever 1 of these. /// </summary> void Awake() { if (!exists) { s_instance = this; exists = true; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); } }