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.UI;
- public class CliclerExample : MonoBehaviour {
- bool doubleClick;
- int money;
- public Text moneyDisplay;
- public Button buttonBuyDoubleClick;
- void Start() {
- money = PlayerPrefs.GetInt("money", 0);
- moneyDisplay.text = money.ToString();
- doubleClick = PlayerPrefs.GetInt("doubleClick", 0) == 1;
- buttonBuyDoubleClick.interactable = !doubleClick;
- }
- public void BuyDoubleClick() {
- doubleClick = true;
- PlayerPrefs.SetInt("doubleClick", 1);
- buttonBuyDoubleClick.interactable = false;
- PlayerPrefs.Save();
- }
- public void Click() {
- if (doubleClick) {
- money += 2;
- } else {
- money++;
- }
- moneyDisplay.text = money.ToString();
- PlayerPrefs.SetInt("money", money);
- PlayerPrefs.Save();
- }
- public void ResetData() {
- PlayerPrefs.DeleteAll();
- money = 0;
- moneyDisplay.text = money.ToString();
- doubleClick = false;
- buttonBuyDoubleClick.interactable = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement