void Start() { connectionAdapter = (ConnectionAdapter)FindObjectOfType(typeof(ConnectionAdapter)); if (connectionAdapter == null) { Debug.LogError("SocketIOAdapter: No object of type ConnectionAdapter was found in the scene."); } socketSim = SocketIOEditorSimulator.Instance; if (socketSim == null) { Debug.LogError("SocketIOAdapter: No SocketIOEditorSimulator.Instance was found in the scene."); } netUpdateHandler = NetworkUpdateHandler.Instance; if (netUpdateHandler == null) { Debug.LogError("SocketIOAdapter: No netUpdateHandler was found in the scene."); } SetName(); }
private void _GetModelsAndSessionDetails () { string SessionDetailsString; #if UNITY_WEBGL && !UNITY_EDITOR if (useEditorModelsList) { #if DEVELOPMENT_BUILD //in dev builds, don't clear models list Debug.LogWarning("Using editor's model list. You should turn off 'Use Editor Models List' off in NetworkManager."); #else //in non-dev build, ignore the flag. modelData.models.Clear(); #endif SessionDetailsString = SocketIOEditorSimulator.GetSessionDetails(); } else { modelData.models.Clear(); SessionDetailsString = SocketIOJSLib.GetSessionDetails(); } if (System.String.IsNullOrEmpty(SessionDetailsString)) { Debug.Log("Error: Details are null or empty."); } else { Debug.Log("SessionDetails: " + SessionDetailsString); var details = JsonUtility.FromJson<SessionDetails>(SessionDetailsString); if (useEditorModelsList) { #if DEVELOPMENT_BUILD //in dev builds, don't pass details to the models list if the flag is enabled. Debug.LogWarning("Using editor's model list. You should turn off 'Use Editor Models List' off in NetworkManager."); #else //in non-dev build, ignore the flag. modelData.models = details.assets; #endif } else { modelData.models = details.assets; } if (sessionName != null) { sessionName = details.session_name; buildName = details.build; } else { Debug.LogError("SessionName Ref in NetworkUpdateHandler's Text Component is missing from editor"); } } #endif }
private void _CreateSocketSimulator() { #if UNITY_WEBGL && !UNITY_EDITOR //don't assign a SocketIO Simulator for WebGL build #else SocketSim = SocketIOEditorSimulator.Instance; if (!SocketSim) { Debug.LogWarning("No SocketIOEditorSimulator was found in the scene. In-editor behavior may not be as expected."); } #endif }
public string GetPlayerNameFromClientID(int clientID) { #if UNITY_WEBGL && !UNITY_EDITOR string SessionDetailsString = SocketIOJSLib.GetSessionDetails(); #else string SessionDetailsString = SocketIOEditorSimulator.GetSessionDetails(); #endif var Details = JsonUtility.FromJson<SessionDetails>(SessionDetailsString); foreach (User user in Details.users) { if (clientID != user.student_id) { continue; } return user.first_name + " " + user.last_name; } return "Client " + clientID; }