public void CreateProfile()
    {
        string name = profileName.text;

        if (PlayerSettings.settings.profileList.Find(i => i.profileName == name) != null)
        {
            print("Profile named " + name + " already exists.");
        }
        else
        {
            PlayerSettings.Profile profile = new PlayerSettings.Profile();
            profile.profileName = name;
            profile.gamesPlayed = 0;
            profile.bestTime    = 60;
            profile.isCurrent   = false;
            profile.avatarPath  = "";
            PlayerSettings.settings.profileList.Add(profile);
            dropdown.options.Add(new Dropdown.OptionData()
            {
                text = profile.profileName
            });
            dropdown.value = 1;
            dropdown.value = 0;
        }
    }
Beispiel #2
0
 public void Delete()
 {
     dropdown.options.RemoveAt(dropdown.value);
     image.texture = null;
     PlayerSettings.Profile profile = PlayerSettings.settings.profileList.Find(i => i.profileName == dropdown.captionText.text);
     PlayerSettings.settings.profileList.Remove(profile);
     dropdown.value = 1;
     dropdown.value = 0;
 }
Beispiel #3
0
    private void SavePlayerPrefs()
    {
        PlayerSettings.Profile currentProfile = PlayerSettings.settings.profileList.Find(i => i.isCurrent == true);

        if (currentProfile != null)
        {
            if (currentProfile.bestTime > Time.timeSinceLevelLoad)
            {
                currentProfile.bestTime = Time.timeSinceLevelLoad;
            }

            currentProfile.gamesPlayed++;
        }
    }
    public void StatisticsUpdate()
    {
        PlayerSettings.Profile currentProfile = PlayerSettings.settings.profileList.Find(i => i.isCurrent == true);

        if (currentProfile != null)
        {
            bestTime.text    = "The Best Time: " + currentProfile.bestTime;
            gamesPlayed.text = "Games Played: " + currentProfile.gamesPlayed;
        }
        else
        {
            bestTime.text    = "The Best Time: " + "???";
            gamesPlayed.text = "Games Played: " + "???";
        }
    }
    public void ChangeAvatar()
    {
        PlayerSettings.Profile currentProfile = PlayerSettings.settings.profileList.Find(i => i.isCurrent == true);
        if (currentProfile != null)
        {
#if UNITY_EDITOR
            currentProfile.avatarPath = EditorUtility.OpenFilePanel("", "", "png");
#else
            currentProfile.avatarPath = inputField.text;
#endif
            if (currentProfile.avatarPath != "")
            {
                StartCoroutine(FinishDownload(currentProfile.avatarPath));
            }
        }
    }