Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- public class Calcolatrice : MonoBehaviour
- {
- public string key = "5211";
- public string entered = "0";
- public Text displayText;
- public void ButtonClicked()
- {
- string bottone = EventSystem.current.currentSelectedGameObject.name;
- Debug.Log(bottone);
- switch (bottone)
- {
- case "Clear":
- entered = "";
- break;
- case "OK":
- if(entered == key)
- {
- entered = "Esatto";
- } else
- {
- entered = "Sbagliato";
- }
- break;
- default:
- int numeroCorrente;
- int.TryParse(entered, out numeroCorrente);
- int numeroBottone;
- int.TryParse(bottone, out numeroBottone);
- int nuovoValore = numeroCorrente * 10 + numeroBottone;
- entered = ""+nuovoValore;
- break;
- }
- displayText.text = entered;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement