Esempio n. 1
0
    public void FillSettingsDisplayWithPlayerPrefs()
    {
        for (int i = 0; i < menuCategories.Count; i++)
        {
            GameObject[] i_settingsRef = menuCategories[i].GetComponent <SettingsMenuOrganizer>().childrenObjects;

            for (int j = 0; j < i_settingsRef.Length; j++)
            {
                UIBehaviour i_thisSetting = i_settingsRef[j].GetComponent <UIBehaviour>();

                if (i_thisSetting is SliderUI)
                {
                    SliderUI i_sliderRef = i_thisSetting as SliderUI;
                    int      value       = Mathf.RoundToInt(PlayerPrefs.GetFloat("REU_" + i_sliderRef.name, i_sliderRef.defaultValue));
                    i_sliderRef.ForceModifyValue(value);
                }
                else if (i_thisSetting is MultichoiceUI)
                {
                    MultichoiceUI i_multiChoiceRef = i_thisSetting as MultichoiceUI;

                    i_multiChoiceRef.ForceModifyValue(PlayerPrefs.GetInt("REU_" + i_multiChoiceRef.name, i_multiChoiceRef.defaultValue));
                }
                else if (i_thisSetting is ToggleUI)
                {
                    ToggleUI i_toggleRef = i_thisSetting as ToggleUI;

                    i_toggleRef.ForceModifyValue(SwissArmyKnife.ConvertPlayerPrefStringAsBool(PlayerPrefs.GetString("REU_" + i_toggleRef.name, i_toggleRef.defaultValueIsYes? "true":"false")));
                }
            }
        }
    }
Esempio n. 2
0
    // Assign saved salues to settings
    public void AssignSavedValuesInSettings()
    {
        for (int i = 0; i < menuCategories.Count; i++)
        {
            GameObject[] i_settingsRef = menuCategories[i].GetComponent <SettingsMenuOrganizer>().childrenObjects;

            for (int j = 0; j < i_settingsRef.Length; j++)
            {
                UIBehaviour i_thisSetting = i_settingsRef[j].GetComponent <UIBehaviour>();

                if (i_thisSetting is SliderUI)
                {
                    SliderUI i_sliderRef = i_thisSetting as SliderUI;

                    foreach (var savedSetting in sliderSettings)
                    {
                        if (savedSetting.Key == i_sliderRef.name)
                        {
                            i_sliderRef.ForceModifyValue(savedSetting.Value);
                        }
                    }
                }
                else if (i_thisSetting is MultichoiceUI)
                {
                    MultichoiceUI i_multiChoiceRef = i_thisSetting as MultichoiceUI;

                    foreach (var savedSetting in multiChoiceSettings)
                    {
                        if (savedSetting.Key == i_multiChoiceRef.name)
                        {
                            i_multiChoiceRef.ForceModifyValue(savedSetting.Value);
                        }
                    }
                }
                else if (i_thisSetting is ToggleUI)
                {
                    ToggleUI i_toggleRef = i_thisSetting as ToggleUI;
                    foreach (var savedSetting in toggleSettings)
                    {
                        if (savedSetting.Key == i_toggleRef.name)
                        {
                            i_toggleRef.ForceModifyValue(savedSetting.Value);
                        }
                    }
                }
            }
        }
    }