/// <summary> /// Create new workout and signal whether to start it /// </summary> /// <param name="GameID">Use the same Game ID for every workout instance</param> /// <param name="start">True to start the workout on creation of the object</param> public void SetupWorkout(string GameID, bool start = true) { if (workout != null) { if (workout.workoutInProgress) { YUR_Log.Log("Workout already in progress, will not setup new workout!"); return; } } if (workout == null || !workout) { workout = this; } DontDestroyOnLoad(workout); gameID = GameID; StartWorkout += Workout_StartWorkout; EndWorkout += Workout_EndWorkout; PauseWorkout += Workout_PauseWorkout; ResumeWorkout += Workout_ResumeWorkout; this.Success += new Workout_Upload(this.SuccessFull_Upload); if (start) { StartingWorkout(); } }
/// <summary> /// Show the YUR User Interface Screen /// </summary> /// <param name="UseYURUISystem">True to use the interaction system included with YUR</param> public void PresentYURGUI(bool UseYURUISystem = true) { if (isActivated) // If screen is already present, return; { return; } YUR_Log.Log("Activating YUR Dash"); isActivated = true; if (Login.Status == Login.StatusType.Logging_In) // True, Subscribe to Successful Login { YUR_UserManager.Successful_Login += Successful_Login_PrepareScreenSystem; YUR_UserManager.Bad_Login += YUR_UserManager_Bad_Login; isActivated = false; return; } else if (Login.Status == Login.StatusType.Logged_In) // True, Show Main Menu on UI call { YURScreenCoordinator.ScreenCoordinator.Hierarchy.Add(YURScreenCoordinator.ScreenCoordinator.MainMenu); //UI.Background.Backgrounds.Instance.SetBackground(YURScreenCoordinator.ScreenCoordinator.MainMenu); } else // Display YUR Initial Login Screen { YURScreenCoordinator.ScreenCoordinator.Hierarchy.Add(YURScreenCoordinator.ScreenCoordinator.InitialMenu); // UI.Background.Backgrounds.Instance.SetBackground(YURScreenCoordinator.ScreenCoordinator.InitialMenu); } StartCoroutine(_presentYURGUI(UseYURUISystem)); // Setup and show the Dash }
/// <summary> /// Used for initial login. Gets required login and persitence tokens /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns></returns> private IEnumerator Acquire_Access_Tokens(string email, string password) { YUR_Log.Log("Logging in with Email and Password"); string response; yield return(response = Systems.Interops.User_AccountAuthorization.Login_User(email, password)); YUR_Log.Log("Received data from Native DLL: " + response); if (response.StartsWith("--1")) { string error = "Login Credentials are invalid"; if (response.Contains("EMAIL_NOT_FOUND")) { error = "Email does not exist, try again"; } Bad_Login?.Invoke(error); yield break; } YUR_Log.Log("Successfully authenticated, begin retrieving data!"); YUR_Log.Server_Log("Received Data: " + response); yield return(CurrentUser.loginCredentials = Utilities.YUR_Conversions.ConvertStringToObject <LoginCredentials>(response)); YUR_Log.Log("Test"); YUR_Log.Log("ActiveUserAccount : " + CurrentUser.loginCredentials.RefreshToken); yield return(StartCoroutine(Get_UserData())); YUR_Log.Log("ActiveUserAccount Refresh Token: " + CurrentUser.loginCredentials.RefreshToken); YUR_Log.Log("ActiveUser PhotoURL: " + CurrentUser.Profile.PhotoURL); YUR_Log.Log("ActiveUserAccount DisplayName: " + CurrentUser.loginCredentials.DisplayName); yield return(YUR_CurrentUser.Store_RefreshToken(CurrentUser.loginCredentials.DisplayName, CurrentUser.Profile.PhotoURL, CurrentUser.loginCredentials.RefreshToken)); Successful_Login?.Invoke("Successfull Login!"); yield break; }
/// <summary> /// Get's the usersdata from database /// </summary> /// <param name="dataType"></param> /// <returns></returns> private IEnumerator Get_UserData(YUR_CurrentUser.DataType dataType = YUR_CurrentUser.DataType.all) { YUR_Log.Server_Log("Retrieving UserData"); if (dataType == YUR_CurrentUser.DataType.all || dataType == YUR_CurrentUser.DataType.biometrics) { YUR_Log.Server_Log("Retrieving Biometric Data with ID token: " + CurrentUser.loginCredentials.IDtoken); string biodata = Systems.Interops.User_AccountAccess.Retrieve_BiometricData(CurrentUser.loginCredentials.IDtoken); YUR_Log.Server_Log("Biometric Data: " + biodata); yield return(CurrentUser.Data_Biometrics = JsonUtility.FromJson <UserData.Biometrics>(biodata)); YUR_Log.Server_Log("Biometric data acquired"); } if (dataType == YUR_CurrentUser.DataType.all || dataType == YUR_CurrentUser.DataType.game_calories) { YUR_Log.Server_Log("Retrieving Game Data with ID token: " + CurrentUser.loginCredentials.IDtoken); string gamedata = Systems.Interops.User_AccountAccess.Retrieve_Game_Data(YUR_Main.main.game_ID, CurrentUser.loginCredentials.IDtoken); YUR_Log.Server_Log("Game Data: " + gamedata); yield return(CurrentUser.Data_Current_Game = Utilities.YUR_Conversions.ConvertStringToObject <UserData.GameData>(gamedata)); YUR_Log.Server_Log("Game data acquired"); } if (dataType == YUR_CurrentUser.DataType.all || dataType == YUR_CurrentUser.DataType.general_calories) { YUR_Log.Server_Log("Retrieving Biometric Data with ID token: " + CurrentUser.loginCredentials.IDtoken); yield return(CurrentUser.Data_General_Calories = Utilities.YUR_Conversions.ConvertStringToObject <UserData.GeneralCalorieData>(Systems.Interops.User_AccountAccess.Retrieve_General_Calorie_Data(CurrentUser.loginCredentials.IDtoken))); YUR_Log.Server_Log("General Calorie data acquired"); } yield break; }
/// <summary> /// Used for initially Creating an anonymous account /// </summary> /// <param name="users_name">The display name of the user</param> /// <returns></returns> private IEnumerator Acquire_Anonymous_Tokens(string users_name) { YUR_Log.Log("Beginning to Login as an Anonymous User"); string response; yield return(response = Systems.Interops.User_AccountCreation.CreateAnonymousAccount()); if (response.StartsWith("--1")) { Bad_Login?.Invoke(response); yield break; } YUR_Log.Log("Successfully authenticated, begin retrieving data!"); yield return(CurrentUser.loginCredentials = Utilities.YUR_Conversions.ConvertStringToObject <LoginCredentials> (response)); YUR_Log.Log("Test"); YUR_Log.Log("ActiveUserAccount : " + CurrentUser.loginCredentials.RefreshToken); yield return(StartCoroutine(Get_UserData())); yield return(YUR_Main.main.User_Manager.CurrentUser.Data_Biometrics.Name = users_name); yield return(YUR_CurrentUser.Store_RefreshToken(CurrentUser.Data_Biometrics.Name, CurrentUser.Profile.PhotoURL, CurrentUser.loginCredentials.RefreshToken)); Successful_Login?.Invoke("Successfull Login!"); yield break; }
/// <summary> /// Login user by their userUID. User must be stored locally /// </summary> /// <param name="userUID">Unique identifier for users</param> /// <returns>String displaying login info</returns> internal string Login_USERID(string userUID) { try { Logging_In?.Invoke("Login using a USER ID Invoked"); YUR_Log.Server_Log("Retrieving locally stored Refresh token"); var combine = Utilities.YUR_Conversions.PathCombine(Application.persistentDataPath, YUR_Constants.USERS_FILEPATH); var usersPath = Utilities.YUR_Conversions.PathCombine(combine, userUID + ".json"); YUR_Log.Log("User Found at: " + usersPath); var userRefresh = System.IO.File.ReadAllText(usersPath); YUR_Log.Log("File contents: " + userRefresh); YUR_CurrentUser.Local_User_Info_Reference tmp = new YUR_CurrentUser.Local_User_Info_Reference(); tmp = Utilities.YUR_Conversions.ConvertStringToObject <YUR_CurrentUser.Local_User_Info_Reference>(userRefresh); YUR_Log.Log("Refresh Token: " + tmp.refresh_token); YUR_Log.Server_Log("Refresh token acquired, passing to Native DLL"); StartCoroutine(Get_IDtoken(tmp.refresh_token)); } catch (System.Exception e) { YUR_Log.Error("Login with Refresh Token Error: " + e); } YUR_Log.Server_Log("Waiting for response from server"); return("Logging in User"); }
/// <summary> /// Obtains required login credentials using a valid refreshtoken and then updates all of the users login details /// </summary> /// <param name="refreshToken">Valid refresh token retrieved from initial login</param> /// <returns></returns> private IEnumerator Get_IDtoken(string refreshToken) { YUR_Log.Log("Getting Login Token with Refresh Token"); string refreshResponse; refreshResponse = Systems.Interops.User_AccountAuthorization.Retrieve_IDToken(refreshToken); if (refreshResponse.StartsWith("--1")) { Bad_Login?.Invoke(refreshResponse); yield break; } if (!CurrentUser.Convert_Refresh_Login(refreshResponse)) { YUR_Log.Error("Get IDToken could not use Convert Refresh Login Method. Login was unnsuccessful."); Login.status = Login.StatusType.Logging_Out; Logout.ActiveUser(); yield break; } yield return(StartCoroutine(Get_UserData())); Successful_Login?.Invoke("Successfull Login!"); yield break; }
/// <summary> /// Retrieve list of Previously logged in users user id's from local storage /// </summary> /// <param name="UserID_List"></param> /// <returns>True if users found, otherwise false</returns> public bool GET_LIST_USERS_IDS(ref List <string> UserID_List) { try { YUR_Log.Log("Retrieving List of User IDS"); UserID_List = new List <string>(); string usersFolder = Utilities.YUR_Conversions.PathCombine(Application.persistentDataPath, YUR_Constants.USERS_FILEPATH); Directory.CreateDirectory(usersFolder); List <string> list = Directory.GetFiles(usersFolder, "*.json", SearchOption.TopDirectoryOnly).ToList(); YUR_Log.Log("List of User Files acquired"); if (list.Count < 1) { return(false); } foreach (string filename in list) { int length = usersFolder.Length; YUR_Log.Log("Length to index: " + length); YUR_Log.Log("Users Folder Path: " + usersFolder); YUR_Log.Log(" File Path: " + filename); string userID = filename.Substring(0, filename.Length - 5); YUR_Log.Log("User ID: " + userID.Substring(length)); UserID_List.Add(userID.Substring(length)); } } catch (System.Exception e) { YUR_Log.Error(e.ToString()); } return(true); }
/// <summary> /// Subscribed to the Unsuccessful Login Event /// </summary> /// <param name="response">Debugging information form server</param> /// <returns></returns> protected virtual string Users_Bad_Login(string response) { Login.status = Login.StatusType.Logged_Out; YUR_Log.Server_Log("Unsuccessful login attempt! Error Information provided"); YUR_Log.Error("Bad Login: " + response); return(response); }
private void Workout_EndWorkout() { workoutInProgress = false; YUR_Log.Log("[Workout | End] Ending Workout" + "\n Calories Burned: " + calories + "\n Identifier: " + identifier + "\n GameID: " + gameID + "\n Start: " + start + "\n End: " + end); return; }
public IEnumerator EndWorkoutRoutine(string Identifier) { if (!workout.workoutInProgress) { YUR_Log.Warning("There is no workout currently in progress to end!"); yield break; } workout.workoutInProgress = false; int Calories; yield return(Calories = (int)Mathf.Floor(Tracking.Calories.EndCalorieCounter())); yield return(new WaitForFixedUpdate()); YUR_Main.main.User_Manager.CurrentUser.Data_Current_Game.Calories_All += Calories; YUR_Main.main.User_Manager.CurrentUser.Data_Current_Game.Calories_Weekly += Calories; YUR_Main.main.User_Manager.CurrentUser.Data_Current_Game.Calories_Today += Calories; YUR_Main.main.User_Manager.CurrentUser.Data_General_Calories.Calories_All += Calories; YUR_Main.main.User_Manager.CurrentUser.Data_General_Calories.Calories_Weekly += Calories; YUR_Main.main.User_Manager.CurrentUser.Data_General_Calories.Calories_Today += Calories; YUR_Main.main.User_Manager.CurrentUser.Data_Current_Session_Calories += Calories; System.TimeSpan t; long duration; yield return(t = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1)); yield return(workout.End_Time = (long)(t.TotalSeconds - workout.Time_Duration_Paused)); yield return(duration = (workout.End_Time - workout.Start_Time)); YUR_Main.main.User_Manager.CurrentUser.Data_Current_Game.Time_Played += duration; YUR_Main.main.User_Manager.CurrentUser.Data_General_Calories.Time_played += duration; YUR_Main.main.User_Manager.CurrentUser.Data_Current_Game.Last_Played = workout.End_Time; YUR_Main.main.User_Manager.CurrentUser.Data_General_Calories.Last_played = workout.End_Time; yield return(workout.Calories += (int)(Calories - workout.Paused_Calories)); yield return(workout.Identifier = Identifier); YUR_Main.main.User_Manager.CurrentUser.SaveAll(); EndWorkout?.Invoke(); yield return(new WaitForSeconds(4)); StartCoroutine(workout.UploadWorkout()); yield break; }
/// <summary> /// Login in User with Email and Password /// </summary> /// <param name="email"></param> /// <param name="password"></param> public void Login_Email_Password(string email, string password) { Logging_In?.Invoke(string.Empty); try { StartCoroutine(Acquire_Access_Tokens(email, password)); } catch (System.Exception e) { YUR_Log.Error(e.ToString()); } }
public IEnumerator LoadSetupCloseBackButtons() { if (YUR.Yur.YURAssetBundle == null) { string URI = "file:///" + Application.dataPath + "/AssetBundles/" + YUR.Yur.assetBundleName; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(URI, 0); yield return(request.SendWebRequest()); if (request.error != null) { yield break; } else { YUR_Log.Log("Local asset bundle found!"); yield return(YUR.Yur.YURAssetBundle = DownloadHandlerAssetBundle.GetContent(request)); } } var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("YUR Back Button"); yield return(BackButton = Instantiate(temppp, gameObject.transform)); // BackButton = (GameObject)Instantiate(Resources.Load("YUR Back Button"), gameObject.transform); BackButton.GetComponent <Button>().onClick.AddListener(delegate { if (BackButtonPressed != null) { BackButtonPressed.Invoke(); } YURScreenCoordinator.ScreenCoordinator.BackButtonPressed(); }); temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("YUR Close Button"); yield return(CloseButton = Instantiate(temppp, gameObject.transform)); // CloseButton = (GameObject)Instantiate(Resources.Load("YUR Close Button"), gameObject.transform); CloseButton.GetComponent <Button>().onClick.AddListener(delegate { if (CloseButtonPressed != null) { CloseButtonPressed.Invoke(); } YURScreenCoordinator.ScreenCoordinator.CloseButtonPressed(); }); if (Finished != null) { Finished.Invoke(); } }
public static void StartingWorkout() { if (workout.workoutInProgress || Login.Status == Login.StatusType.Logged_Out) { YUR_Log.Warning("<b>Workout is either already in progress or there is no user logged in!</b>"); return; } StartWorkout?.Invoke(); Tracking.Calories.StartCalorieCounter(); System.TimeSpan t = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1); workout.Calories = 0; workout.Start_Time = (long)t.TotalSeconds; return; }
IEnumerator GET_FILE(SERVER_FILE file) { string url; if (file == SERVER_FILE.TOS) { url = "https://yurapp-502de.firebaseapp.com/Doc/termsofservice.txt"; } else if (file == SERVER_FILE.PP) { url = "https://yurapp-502de.firebaseapp.com/Doc/privacypolicy.txt"; } else if (file == SERVER_FILE.EULA) { url = "https://yurapp-502de.firebaseapp.com/Doc/enduserlicenseagreement.txt"; } else { url = "https://yurapp-502de.firebaseapp.com/api/v1/hidden/running"; } var uwr = new UnityWebRequest(url, "GET"); uwr.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); yield return(uwr.SendWebRequest()); if (uwr.isNetworkError) { YUR_Log.Server_Log("Network Error occured while retrieving documents"); } else { switch (file) { case SERVER_FILE.PP: PrivacyPolicy = uwr.downloadHandler.text; StartCoroutine(GET_FILE(SERVER_FILE.TOS)); break; case SERVER_FILE.TOS: TermsOfService = uwr.downloadHandler.text; StartCoroutine(GET_FILE(SERVER_FILE.EULA)); break; case SERVER_FILE.EULA: EndUserLicenseAgreement = uwr.downloadHandler.text; break; } } }
public void Awake() { if (instance == null) { instance = this; } if (!YUR.Yur.Settings.SceneBasedWorkouts) { YUR_Log.Log("Scene Based Workouts are disabled"); return; } SceneManager.sceneLoaded += SceneManager_sceneLoaded; }
public string TimePlayed(ref UserData.GameData UserDataClass) { YUR_Log.Log("Time Played: " + UserDataClass.Time_Played); TimeSpan btime = TimeSpan.FromSeconds(UserDataClass.Time_Played); YUR_Log.Log("Time Span: " + btime); int Days = btime.Days; int Weeks = 0; WeekCalculate(ref Days, ref Weeks); string ret = (Weeks > 0 ? Weeks + "w " : "") + (Days > 0 ? Days + "d " : "") + btime.Hours.ToString() + "h " + btime.Minutes.ToString() + "m " + btime.Seconds.ToString() + "s"; return(ret); }
/// <summary> /// Updates specified data from database /// </summary> /// <param name="dataType"></param> /// <returns></returns> internal IEnumerator Refresh_Token_Set_Data(YUR_CurrentUser.DataType dataType) { string refreshResponse; yield return(refreshResponse = Systems.Interops.User_AccountAuthorization.Retrieve_IDToken(CurrentUser.loginCredentials.IDtoken)); if (refreshResponse.StartsWith("--1")) { Bad_Login?.Invoke(refreshResponse); yield break; } YUR_Log.Log("Refresh token worked! Setting all other data"); yield return(CurrentUser.Convert_Refresh_Login(refreshResponse)); StartCoroutine(Set_UserData(dataType)); yield break; }
public static void GetCameraObject(ref GameObject Camera) { try { if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.OCULUS) { var oculusGobject = UnityOculusLibrary.OculusHelpers.GetPlayer(); if (oculusGobject != null) { Camera = oculusGobject; return; } } var gobject = GameObject.FindGameObjectsWithTag(YUR.Yur.Settings.CameraTag); if (gobject.Length < 0) { YUR_Log.Log("Unable to find any objects with tag"); return; } foreach (var obj in gobject) { if (obj.name.Contains("eye")) { Camera = obj; return; } } } catch (System.Exception e) { YUR_Log.Warning("Error while getting camera: " + e); //var gobject = GameObject.FindGameObjectsWithTag(YUR.Yur.Settings.CameraTag); //foreach (var obj in gobject) //{ // if (obj.name.Contains("eye")) // { // return obj; // } //} } YUR_Log.Warning("Was unable to locate a valid camera tagged " + YUR.Yur.Settings.CameraTag); return; }
internal IEnumerator UploadWorkout() { yield return(new WaitForSeconds(1)); YUR_Log.Server_Log("Uploading workout"); string response; string objectasstring; yield return(objectasstring = Utilities.YUR_Conversions.ConvertObjectToString(this)); yield return(response = Systems.Interops.Workouts.UploadWorkout(objectasstring, YUR_Main.main.User_Manager.CurrentUser.loginCredentials.IDtoken)); if (response.StartsWith("--1")) { Failure?.Invoke(response); yield break; } Success?.Invoke(response); yield break; }
/// <summary> /// Used for Creating a new account. Creates an account and then signs the user in. /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <param name="displayName"></param> /// <returns></returns> private IEnumerator Create_New_Account_Email_Password(string email, string password, string displayName) { YUR_Log.Server_Log("Creating an account with Email and Password"); string response; yield return(response = Systems.Interops.User_AccountCreation.CreateAccount(email, password, displayName)); if (response.StartsWith("--1")) { Bad_Login?.Invoke("Account Creation Failed: " + response); yield break; } YUR_Log.Server_Log("Account creation was successful, waiting for profile to build"); yield return(new WaitForSeconds(3)); Logging_In?.Invoke("Attempting to Login to account"); yield return(StartCoroutine(Acquire_Access_Tokens(email, password))); yield break; }
private void Workout_StartWorkout() { workoutInProgress = true; YUR_Log.Log("[Workout | Start] Starting workout"); return; }
void OnEnable() { YUR_Log.Log("Enabled Screens_LoginEmailPassword"); YURScreenCoordinator.ScreenCoordinator.Keyboard.SetActive(true); }
internal static string Retrieve_IDToken(string refreshToken) { YUR_Log.Server_Log("Passing over to native dll, waiting for response..."); return(Marshal.PtrToStringAnsi(Get_IDToken(refreshToken))); }
/// <summary> /// Get the Tokens necessary for all other User Account access actions /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns>idToken and Refresh token</returns> internal static string Login_User(string email, string password) { YUR_Log.Log("Piping login over to Native DLL"); return(Marshal.PtrToStringAnsi(LoginYURUser(email, password))); }
/// <summary> /// Create the dash and present it /// </summary> /// <returns></returns> private IEnumerator _presentYURGUI(bool UsingYURinteractionSystem) { Vector3 YUR_Position; Vector3 YUR_Direction; /// Display the ScreenCoordinator Object and set the background color of the Dash YURScreenCoordinator.ScreenCoordinator.gameObject.SetActive(true); YURScreenCoordinator.ScreenCoordinator.Background.GetComponent <UnityEngine.UI.Image>().color = YUR.Yur.BackgroundColor; GameObject Camera = YUR.Yur.Camera; /// If a previously specified gameobject is to be used for the location of dash. if (YUR.Yur.GUITransform != null) { Debug.Log("Displaying on GUITransform", YUR.Yur.GUITransform); YUR.Yur.YUR_Dash.transform.localScale = new Vector3(YUR.Yur.YUR_Dash.transform.localScale.x * (YUR.Yur.YURGUIScale + 1), YUR.Yur.YUR_Dash.transform.localScale.y * (YUR.Yur.YURGUIScale + 1), YUR.Yur.YUR_Dash.transform.localScale.z * (YUR.Yur.YURGUIScale + 1)); YUR.Yur.YUR_Dash.transform.SetParent(YUR.Yur.GUITransform.transform); YUR.Yur.YUR_Dash.transform.localPosition = YUR.Yur.YURGUIPositionOffset; YUR.Yur.YUR_Dash.transform.localEulerAngles = YUR.Yur.YURGUIRotationOffset; } else /// Else, position the dash relative to the camera position; { YUR_Log.Log("Moving Dash in front of player"); YUR_Position = Camera.transform.position; YUR_Direction = Camera.transform.forward; YUR_Direction.y = 0; YUR_Log.Log("Dash Positioning: \nPosition: " + YUR_Position + "\nDirection: " + YUR_Direction + "\nYUR Dash Position: " + YUR.Yur.YUR_Dash.transform.position, YUR.Yur.YUR_Dash); YUR.Yur.YUR_Dash.transform.SetPositionAndRotation( new Vector3(YUR_Position.x + (YUR_Direction.x * 2), YUR_Position.y, YUR_Position.z + (YUR_Direction.z * 2)), Quaternion.LookRotation(YUR_Direction)); YUR_Log.Log("Dash Positioning: \nPosition: " + YUR_Position + "\nDirection: " + YUR_Direction + "\nYUR Dash Position: " + YUR.Yur.YUR_Dash.transform.position, YUR.Yur.YUR_Dash); } /// Present the first screen to user YURScreenCoordinator.ScreenCoordinator.Hierarchy[0].gameObject.SetActive(true); bool leftHanded = false; bool instantiatedUIKit = false; int children; /// Deteremine the number of children in which the Camera object has, differing counts are for different platforms if (Camera.transform.parent) { children = Camera.transform.parent.childCount; } else { children = Camera.transform.childCount; } if (!UsingYURinteractionSystem) // If Not using YUR Interaction System, stop here { yield break; } if (YUR.Yur.YURAssetBundle == null) { string URI = "file:///" + Application.dataPath + "/AssetBundles/" + YUR.Yur.assetBundleName; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(URI, 0); yield return(request.SendWebRequest()); if (request.error != null) { yield break; } else { YUR_Log.Log("Local asset bundle found!"); yield return(YUR.Yur.YURAssetBundle = DownloadHandlerAssetBundle.GetContent(request)); } } ////_____________________________________________________________________________________/ /// Take Control of the Event System, is returned when YUR Dash is closed. //_____________________________________________________________________________________/ OriginalEventSystem = UnityEngine.EventSystems.EventSystem.current; if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.OCULUS) { GameObject temppp; yield return(temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("LaserInputModuleOculus")); YUR_Log.Log("Loaded the Laser Input Module for Oculus, instantiating"); yield return(EventSystem = (Instantiate(temppp) as GameObject));// = EventSystem.gameObject.AddComponent<VRUiKits.Utils.OculusLaserInputModule>(); EventSystem.name = "Event System"; UnityEngine.EventSystems.EventSystem.current = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>(); YUR.Yur.eventSystem = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>(); yield return(LaserIM = EventSystem.GetComponent <VRUiKits.Utils.LaserInputModule>()); YUR_Log.Log("Oculus Input Module Added"); } else if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.VIVE_STEAM2) { var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("LaserInputModuleSteam2"); yield return(EventSystem = (Instantiate(temppp) as GameObject));// = EventSystem.gameObject.AddComponent<VRUiKits.Utils.OculusLaserInputModule>(); EventSystem.name = "Event System"; UnityEngine.EventSystems.EventSystem.current = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>(); YUR.Yur.eventSystem = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>(); yield return(LaserIM = EventSystem.GetComponent <VRUiKits.Utils.LaserInputModule>()); YUR_Log.Log("Steam Input Module Added"); } if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.OCULUS) /// If the platform is defined as being Oculus, use the Camera object to locate the Controllers { YUR_Log.Log("Locating Oculus Controllers..."); for (int i = 0; i < YUR.Yur.Camera.transform.parent.childCount; i++) { if (YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.name.Contains("RightHand")) { var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("OculusUIKitPointer"); UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform); //UIPointerKit = (GameObject)Instantiate(Resources.Load("OculusUIKitPointer"), YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform); instantiatedUIKit = true; leftHanded = false; YUR_Log.Log("Found Oculus Controller Right"); break; } else if (YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.name.Contains("LeftHand")) { var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("OculusUIKitPointer"); UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform); //UIPointerKit = (GameObject)Instantiate(Resources.Load("OculusUIKitPointer"), YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform); instantiatedUIKit = true; leftHanded = true; YUR_Log.Log("Found Oculus Controller Left"); break; } } } else if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.VIVE_STEAM2) /// If the platform is Steam VR 2, find the preferred controller. { YUR_Log.Log("Locating Steam VR 2 Controllers..."); for (int i = 0; i < children; i++) { Debug.Log("Found Controller: " + Camera.transform.parent.GetChild(i).gameObject.name); if (Camera.transform.parent.GetChild(i).gameObject.name.Contains("right")) { var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("Steam2UIKitPointer"); UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform); // UIPointerKit = (GameObject)Instantiate(Resources.Load("Steam2UIKitPointer"), Camera.transform.parent.GetChild(i).gameObject.transform); instantiatedUIKit = true; leftHanded = false; YUR_Log.Log("Found Steam Controller right"); break; } if (Camera.transform.parent.GetChild(i).gameObject.name.Contains("left")) { var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("Steam2UIKitPointer"); UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform); // UIPointerKit = (GameObject)Instantiate(Resources.Load("Steam2UIKitPointer"), Camera.transform.parent.GetChild(i).gameObject.transform); instantiatedUIKit = true; leftHanded = true; YUR_Log.Log("Found Steam Controller Left"); break; } } } LaserIM.platform = YUR.Yur.platform; LaserIM.pointer = (leftHanded ? VRUiKits.Utils.Pointer.LeftHand : VRUiKits.Utils.Pointer.RightHand); if (!instantiatedUIKit) // If UIPointerKit not previously instantiated { var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("UIKitPointer"); UIPointerKit = Instantiate(temppp); //UIPointerKit = (GameObject)Instantiate(Resources.Load("UIKitPointer")); } //YUR_Log.Log("Checking for event system..."); //if (YUR.Yur.eventSystem == null) // If there is no event system, create a new gameobject and attach an Event System Component //{ // YUR_Log.Log("None found, create event system..."); // //EventSystem = new GameObject("EventSystem"); // //yield return YUR.Yur.eventSystem = EventSystem.AddComponent<UnityEngine.EventSystems.EventSystem>(); //} //else //{ // YUR_Log.Log("Found event System"); // EventSystem = YUR.Yur.eventSystem.gameObject; //} //if(EventSystem.gameObject.GetComponent<VRUiKits.Utils.VREventSystemHelper>()) //{ // YUR_Log.Log("VR Event System Helper already added to game object"); //} //else //{ // YUR_Log.Log("Adding Event System Helper and Input Module"); // EventSystem.gameObject.AddComponent<VRUiKits.Utils.VREventSystemHelper>(); //} }
/// <summary> /// Subscribed to the Successful Login Event /// </summary> /// <param name="response">Debugging information form server</param> /// <returns>String Reporting Login Status</returns> protected virtual string Users_Successful_Login(string response) { Login.status = Login.StatusType.Logged_In; YUR_Log.Server_Log("Login attempt was successful!"); return(response); }
IEnumerator Setup() { YUR_Log.Log("Setting up Profile"); yield return(User = UserManagement.YUR_UserManager.YUR_Users.CurrentUser); YUR_Log.Log("Retrieved the user manager"); Title.text = User.Data_Biometrics.Name + "'s Profile"; UpdateAge(); /// BirthDate //////////////////////////////////// BirthDate.Day.PlaceHolder.text = "Day"; BirthDate.Day.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.BirthDate[2]; BirthDate.Month.PlaceHolder.text = "Month"; BirthDate.Month.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.BirthDate[1]; BirthDate.Year.PlaceHolder.text = "Year"; BirthDate.Year.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.BirthDate[0]; /// Units //////////////////////////////////// if (User.Data_Biometrics.Metric_Units) { Units.selectedValue = "Metric"; /// Weight Weight.PlaceHolder.text = "kgs"; Weight.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.metric.Weight.ToString(); Weight.Label.text = "Weight: (in kilograms)"; /// Height Height.PlaceHolder.text = "cm"; Height.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = (User.Data_Biometrics.metric.Height * 100).ToString(); Height.Label.text = "Height: (in centimeters)"; } else { Units.selectedValue = "Customary"; /// Weight Weight.PlaceHolder.text = "lbs"; Weight.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.customary.Weight.ToString(); Weight.Label.text = "Weight: (in pounds)"; /// Height Height.PlaceHolder.text = "in"; Height.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.customary.Height.ToString(); Height.Label.text = "Height: (in inches)"; } /// Sex /////////////////////////////////////// if (User.Data_Biometrics.Sex == "male") { Sex.selectedValue = "Male"; } else if (User.Data_Biometrics.Sex == "female") { Sex.selectedValue = "Female"; } else { Sex.selectedValue = "Unspecified"; } Units.NextPressed += Units_PrevPressed; Units.PrevPressed += Units_PrevPressed; Sex.NextPressed += Sex_NextPressed; Sex.PrevPressed += Sex_PrevPressed; YURScreenCoordinator.ScreenCoordinator.Keyboard.SetActive(true, KeyboardCanvas.KeyboardStyle.KeyboardNumPad); yield break; }
/// <summary> /// Subscribed to the Logging in Event /// </summary> /// <param name="response"></param> /// <returns></returns> protected virtual string Users_Logging_In(string response) { Login.status = Login.StatusType.Logging_In; YUR_Log.Server_Log("An account began to Log in"); return(response); }
/// <summary> /// Subscribed to the Already_Logged_In event /// </summary> /// <param name="response">Pertinent information</param> /// <returns>Pertinent information</returns> internal virtual string Users_Already_Logged_In(string response) { YUR_Log.Server_Log("Login attempt while other user still logged in was made!"); return(response); }