コード例 #1
0
    // TODO Just for test purposes -> Delete in production
    public static void TestSetCurrentUser()
    {
        string allUsersFilePath = "/StreamingAssets/JSONData/Users/";

        DirectoryInfo directoryInfo = new DirectoryInfo(Application.dataPath + allUsersFilePath);

        FileInfo[] files = directoryInfo.GetFiles();
        currentUserDataObject = new UserDataObject();

        foreach (var file in files)
        {
            if (file.Extension.Contains("json"))
            {
                string filePath      = Application.dataPath + allUsersFilePath + file.Name;
                string alluserAsJson = File.ReadAllText(filePath);

                UserData tempUserData = JsonUtility.FromJson <UserData>(alluserAsJson);

                if (tempUserData.isCurrentUser == true)
                {
                    Debug.Log("TEST CURRENT USER: "******"CurrentUser", tempUserData.name);
                    PlayerPrefs.SetString("CurrentUserFilePath", filePath);
                    PlayerPrefs.SetInt("CurrentTierId", 0);
                }
            }
        }
    }
コード例 #2
0
    private void ClickOnUser(UserData user, string filePath)
    {
        PlayerPrefs.SetString("CurrentUser", user.name);
        PlayerPrefs.SetString("CurrentUserFilePath", filePath);
        PlayerPrefs.SetInt("CurrentTierId", 0);

        currentUserDataObject.SetCurrentUser(user);
        Debug.Log(currentUserDataObject.GetCurrentUser());
        Debug.Log(currentUserDataObject.GetCurrentUser().name);

        SceneManager.LoadScene("TierMenu");
    }