private void OnUserDisconnect(SocketIOEvent obj) { User user = JsonUtility.FromJson <User>(obj.data.ToString()); Debug.Log(user.name + " disconnected."); TrialPlayerController disconnectedPlayer = users.Find(item => item.name == user.name); this.users.Remove(disconnectedPlayer); GameObject disconnectedPlayerObject = disconnectedPlayer.gameObject; Destroy(disconnectedPlayer); Destroy(disconnectedPlayerObject); }
private void OnUserLoggedIn(SocketIOEvent obj) { User user = JsonUtility.FromJson <User>(obj.data.ToString()); currentUser = new User(); currentUser = user; player = GameObject.FindGameObjectWithTag("Player"); TrialPlayerController playerController = player.GetComponent <TrialPlayerController>(); playerController = (playerController == null) ? player.AddComponent <TrialPlayerController>() : playerController; playerController.externalPlayer = true; player.name = user.name; playerController.name = user.name; this.users.Add(playerController); }