salahzar

Calcolatrice.cs

Apr 11th, 2021
416
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6.  
  7. public class Calcolatrice : MonoBehaviour
  8. {
  9.     public string key = "5211";
  10.     public string entered = "0";
  11.     public Text displayText;
  12.     public void ButtonClicked()
  13.     {
  14.         string bottone = EventSystem.current.currentSelectedGameObject.name;
  15.         Debug.Log(bottone);
  16.         switch (bottone)
  17.         {
  18.             case "Clear":
  19.                 entered = "";
  20.                 break;
  21.             case "OK":
  22.                 if(entered == key)
  23.                 {
  24.                    entered = "Esatto";
  25.                 } else
  26.                 {
  27.                    entered = "Sbagliato";
  28.                 }
  29.                 break;
  30.  
  31.             default:
  32.                 int numeroCorrente;
  33.                 int.TryParse(entered, out numeroCorrente);
  34.                 int numeroBottone;
  35.                 int.TryParse(bottone, out numeroBottone);
  36.                 int nuovoValore = numeroCorrente * 10 + numeroBottone;
  37.                 entered = ""+nuovoValore;
  38.                 break;
  39.         }
  40.         displayText.text = entered;
  41.  
  42.  
  43.     }
  44. }
  45.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×