// Use this for initialization void Awake() { //check to see if we already have an existing EasyWiFiManager from another scene //if we do destroy this one foreach (var gameObj in FindObjectsOfType(typeof(EasyWiFiManager))) { if (gameObj.GetInstanceID() == this.GetInstanceID()) { //this is the current gameobject ignore } else { //another one must have been present from another scene so destroy the one we're currently in since the other one has active connections DestroyImmediate(this.gameObject); return; } } Screen.sleepTimeout = SleepTimeout.NeverSleep; if (peerType == EasyWiFiConstants.PEER_TYPE.Server) { EasyWiFiController.initialize(applicationName, EasyWiFiConstants.PEERTYPE_SERVER, serverSocketPort, clientSocketPort, logVerbose, clientConnectAutomatically); } else { EasyWiFiController.initialize(applicationName, EasyWiFiConstants.PEERTYPE_CLIENT, serverSocketPort, clientSocketPort, logVerbose, clientConnectAutomatically); } DontDestroyOnLoad(transform.gameObject); }