[SKKU DT] 18일차 -유니티 기본 테스트 -버튼을 눌러서 +, - 1씩 적용하는 유니티 씬 만들기

2023. 11. 22. 18:35SKKU DT

728x90
반응형

버튼을 눌러서 +, - 1씩 적용하는 유니티 씬 만들기

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class TextScript : MonoBehaviour
{
    //현재 점수
    public TextMeshProUGUI textNumber;
    public int currentNumber = 0;
    // Start is called before the first frame update
    void Start()
    {
        textNumber.text = "0";
    }
    public void Plus()
    {
        currentNumber++;
        textNumber.text = currentNumber.ToString();
    }
    public void Minus()
    {
        currentNumber--;
        textNumber.text = currentNumber.ToString();
    }
}
728x90
반응형