/// <summary> /// Change response from Refresh Token login into valid login credentials /// </summary> /// <param name="jsonResponse"></param> /// <param name="yURaccount"></param> /// <returns></returns> public bool Convert_Refresh_Login(string jsonResponse) { try { YUR_Log.Log("Extracting data from class: " + jsonResponse); Temp_Class temp_class = new Temp_Class(); temp_class = JsonUtility.FromJson <Temp_Class>(jsonResponse); YUR_Log.Log("Temporary class: " + JsonUtility.ToJson(temp_class)); loginCredentials.LocalId = temp_class.user_id; loginCredentials.RefreshToken = temp_class.refresh_token; loginCredentials.IDtoken = temp_class.id_token; YUR_Log.Log("Conversion, items passed: " + JsonUtility.ToJson(this)); if (loginCredentials.IDtoken == "" || loginCredentials.IDtoken == string.Empty || loginCredentials.IDtoken == null) { return(false); } return(true); } catch (Exception e) { YUR_Log.Error("Convert Refresh Login Failed with Error: " + e); return(false); } }
/// <summary> /// Log a user in by their User ID (UID). Necessary for persistant logins /// </summary> /// <param name="userID"></param> /// <returns></returns> public static bool User_ID(string userID) { try { YUR_Main.main.User_Manager.Login_USERID(userID); } catch (Exception e) { YUR_Log.Error("User_ID login attempt error: " + e); } return(true); }
/// <summary> /// Called upon creation of YUR object /// </summary> /// <param name="game_ID"></param> /// <param name="Fixed_Time_Step"></param> /// <param name="debug"></param> /// <param name="error_debug"></param> public void StartUp(string game_ID = "yurapp", float Fixed_Time_Step = 90, bool debug = false, bool error_debug = true, bool server_debug = false, bool log_to_file = false, bool auto_sign_in = false, bool editor_debugging = true) { main = this; DontDestroyOnLoad(main); DontDestroyOnLoad(this); this.game_ID = game_ID; TimeStep = Fixed_Time_Step; this.auto_sign_in = auto_sign_in; YUR_Log.Debugging = debug; YUR_Log.Error_Logging = error_debug; YUR_Log.Server_Logging = server_debug; YUR_Log.Log_To_File = log_to_file; YUR_Log.Editor_Debugging = editor_debugging; YUR_Log.Log("Starting YUR"); workout = gameObject.AddComponent <Workouts.Workout>(); calories = new GameObject("YUR Calorie Display Object").AddComponent <Tracking.Calories>(); DontDestroyOnLoad(workout); // TODO Check DontDestroyOnLoads are not over done. Placed everywhere as a quick fix DontDestroyOnLoad(calories); YUR_UserManager.Successful_Login += new YUR_UserManager.Login_Status_Changed(Active_User_Logged_In_Successfully); YUR_UserManager.Bad_Login += new YUR_UserManager.Login_Status_Changed(Active_User_Unable_To_Login); YUR_Log.Log("Subscribed to events"); try { YUR_Log.Log("Getting Last Logged In User ID"); string path = Utilities.YUR_Conversions.PathCombine(Application.persistentDataPath, YUR_Constants.LAST_ACTIVE_USER_FILEPATH); Directory.CreateDirectory(path); path += "active.txt"; YUR_Log.Log("Looking here: " + path); if (File.Exists(path)) { Last_Played_User = File.ReadAllText(path); YUR_Log.Log("Last uid: " + Last_Played_User); } else { YUR_Log.Log("Last user was not saved!"); } StartCoroutine(LoadUsers()); } catch (System.Exception e) { YUR_Log.Error(e.ToString()); } }
public void Start() { if (!enabled) { YUR_Log.Error("YUR is not enabled!"); return; } if (YUR.Yur == null) { _yur = this; } else { YUR_Log.Log("YUR is already setup"); DestroyImmediate(this); return; } /// Instantiate YUR Main Object /// YUR_GO = new GameObject("[YUR]"); /// Load General Settings /// Settings = Resources.Load("YURGeneralSettings") as YURSettingsScriptableObject; AutoUpdate = Settings.AutomaticUpdates; if (!Settings.SceneBasedWorkouts || Settings.StartWorkoutScenes == null || Settings.StartWorkoutScenes.Length <= 0) { YUR_Log.Warning("Scene based workouts is set to false. If this is a mistake, please ensure that you have at least 1 scene setup to start a workout"); Settings.SceneBasedWorkouts = false; } else { var WorkoutsManager = new GameObject("[Workouts]"); WorkoutsManager.transform.SetParent(YUR_GO.transform); _sceneWorkoutManager = WorkoutsManager.AddComponent <Workouts.YUR_SceneWorkoutManager>(); } CalorieDisplay = new GameObject("Calorie Display"); //TODO Calorie Display object is most likely instantiated elsewhere DontDestroyOnLoad(CalorieDisplay); /// Setup all AOT variables inside here if (Application.platform == RuntimePlatform.Android) { AutoUpdate = false; } var mainCameras = GameObject.FindGameObjectsWithTag(Settings.CameraTag); if (mainCameras.Length > 0) { foreach (var camera in mainCameras) { _mainCamera = camera; break; } } else { YUR_Log.Warning("Unable to locate the Camera using tag..."); } YUR_Log.Log("Starting to get YUR Object and startup system"); StartCoroutine(InstantiateYURObjects()); _eventSystem = UnityEngine.EventSystems.EventSystem.current; YUR_Main.Completed_Startup += YUR_Main_Completed_Startup; Fit = YUR_Script_Helper.Setup_YUR_Object(YUR_GO, Settings.GameID, Settings.debugging, Settings.ErrorDebugging, Settings.ServerDebugging, Settings.WriteDebuggingToFile, Settings.AutomaticallySignInUser); YURGesture = YUR_GO.AddComponent <YUR_GestureRecognition>(); platform = Settings.platform; if (platform != VRUiKits.Utils.VRPlatform.VIVE_STEAM2) { LeftControllerTrigger = Settings.LeftControllerButton; RightControllerTrigger = Settings.RightControllerButton; } this.gameObject.transform.SetParent(YUR_GO.transform); DontDestroyOnLoad(this); //UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneManager_sceneLoaded; }