示例#1
0
 /// <summary>
 /// Método SetLanguage, que cambia el idioma
 /// </summary>
 /// <param name="resolutionIndex"></param>
 public void SetLanguage(int languageIndex)
 {
     if (currentLanguageIndex != languageIndex)
     {
         LocalizationSystem.language = LocalizationSystem.GetLanguageByIndex(languageIndex);
         LocalizationTexts.instance.UpdateTexts();
         currentLanguageIndex = languageIndex;
         //languageSelectedBackground.rectTransform.localPosition = new Vector3(languageSelectedBackground.rectTransform.localPosition.x, backgroundPositions[currentLanguageIndex], 0);
         // Se mueven los puntos de anclaje (que son independientes del tamaño de la pantalla, van de 0 a 1) y se centra la imagen
         languageSelectedBackground.rectTransform.anchorMin        = new Vector2(languageSelectedBackground.rectTransform.anchorMin.x, backgroundPositions[currentLanguageIndex][0]);
         languageSelectedBackground.rectTransform.anchorMax        = new Vector2(languageSelectedBackground.rectTransform.anchorMax.x, backgroundPositions[currentLanguageIndex][1]);
         languageSelectedBackground.rectTransform.anchoredPosition = new Vector2(0, 0);
         WriteOptions();
     }
 }
示例#2
0
    /// <summary>
    /// Método ReadOptions, que lee las opciones guardadas del jugador
    /// </summary>
    private void ReadOptions()
    {
        // PlayerPrefs
        musicVolume   = PlayerPrefs.GetFloat("musicVolume", 0.5f);
        fxVolume      = PlayerPrefs.GetFloat("fxVolume", 0.5f);
        brightnessLvl = PlayerPrefs.GetFloat("brightnessLvl", 0.5f);
        int languageIndex = PlayerPrefs.GetInt("languageIndex", 0);

        foreach (Audio a in AudioManager.instance.music)
        {
            a.source.volume = musicVolume * a.volume;
        }

        foreach (Audio a in AudioManager.instance.sounds)
        {
            a.source.volume = fxVolume * a.volume;
        }

        LocalizationSystem.language = LocalizationSystem.GetLanguageByIndex(languageIndex);
        LocalizationTexts.instance.UpdateTexts();
    }