-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuAjustes.cs
54 lines (50 loc) · 1.36 KB
/
MenuAjustes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections;
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEditor;
using TMPro;
using System.Text.RegularExpressions;
using System;
public class MenuAjustes : MonoBehaviour
{
static float volumen = 1f;
static int velocidad = 0;
public TextMeshProUGUI textoError;
public Slider barraVolumen;
public TextMeshProUGUI inputVelocidad;
private void OnDisable()
{
PlayerPrefs.SetFloat("volumen", volumen);
PlayerPrefs.SetInt("velocidad", velocidad);
}
public void ActualizarVolumen(float nuevoVolumen)
{
volumen = nuevoVolumen;
}
public void ActualizarVelocidad(string nuevaVelocidad)
{
try
{
int n = int.Parse(nuevaVelocidad);
if (n >= 0 && n <= 100)
{
velocidad = n;
textoError.text = "";
}
else
{
textoError.text = "Solo puedes introducir números comprendidos entre 0 y 100";
}
} catch (FormatException) {
textoError.text = "Solo puedes introducir números comprendidos entre 0 y 100";
}
}
public void ActualizarValores()
{
barraVolumen.value = volumen;
inputVelocidad.text = velocidad.ToString();
}
}