0

Tengo el siguiente código:

public class Language : MonoBehaviour {

public int ingles = 1;

public string[] Texto_ingles;

public string[] Texto_español;

public Text[] Text;

public Button boton_español, boton_ingles;
// Update is called once per frame
/*void Update () {
    cambiarIdioma ();
}*/

void Start(){
    Button boton_español = gameObject.GetComponent<Button> ();
    Button boton_ingles = gameObject.GetComponent<Button> ();

}
void Update(){

//  boton_español.onClick.AddListener (IdiomaEspañol ());
//  boton_ingles.onClick.AddListener (IdiomaEspañol ());
    //
}

public void cambiarIdioma(){
    /*if (ingles == 0) IdiomaIngles ();
    if (ingles == 1) IdiomaEspañol ();*/

    if (boton_español.onClick.AddListener (IdiomaEspañol ())) {
        PlayerPrefs.SetInt ("Idioma",IdiomaEspañol);
        PlayerPrefs.Save ();

    }
    if (boton_ingles.onClick.AddListener (IdiomaIngles ())) {
        PlayerPrefs.SetInt ("Idioma",IdiomaIngles);
        PlayerPrefs.Save ();

    }


}

public void IdiomaIngles(){

    if (Text [0] != null) Text [0].text = Texto_ingles [0];
    if (Text [1] != null) Text [1].text = Texto_ingles [1];
}

public void IdiomaEspañol(){
    if (Text [0] != null) Text [0].text = Texto_español [0];
    if (Text [1] != null) Text [1].text = Texto_español [1];
}

}

Estaba intentando detectar idioma de serie del dispositivo pero incapaz, pero mediante botones tampoco,...

1 respuesta 1

0

Lo que te puedo recomendar es utilizar archivos JSON para el manejo de multi-languages, ya que es mucho mas practico a la hora de cambiar estos.

https://docs.unity3d.com/Manual/JSONSerialization.html

A la ves utilizar un diccionario para el manejo del texto, el cual solo cambia sus caracteres según el idioma que este seleccionado permitiendo cambiarlo en run-time.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.