private void Awake() { if (Instance != null) { Destroy(this); } else { Instance = this; DontDestroyOnLoad(this); Initiate(); } }
//create the network channel and have get a reference to the custom event stream void Start() { CES = CustomEventStream.Instance; CES.CreateChannel(DefaultNetworkOutChannel); CES.CreateChannel(DefaultNetworkInChannel); CES.Subscribe(NetEventHandler, DefaultNetworkInChannel); Debug.Log("trying hosting"); NetworkConnectionError nce = Host(); if (nce == NetworkConnectionError.CreateSocketOrThreadFailure) { Debug.Log(nce); Debug.Log("host failed; assuming already exists. connecting"); Connect(DefaultIp); } else { Debug.Log("success"); } }