-
[Unity] Score 스크립트 만들기Unity/게임 만들어보기 기록장 2022. 10. 22. 19:09728x90
1. UI - Canvas 클릭
2.스코어가 들어갈 Text클릭
3. 위치를 설정해준다
4.점수가 올라갈 영역을 만들어 준다
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public static int score = 0; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { GetComponent<Text>().text = score.ToString(); } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScoreUp : MonoBehaviour { private void OnTriggerEnter2D(Collider2D other) { Score.score++; } }
728x90'Unity > 게임 만들어보기 기록장' 카테고리의 다른 글
[Unity] Score 초기화 및 Best Score (0) 2022.10.24 [Unity]GameOver Scene만들기 (0) 2022.10.23 [Unity] Prefab을 이용하여 파이프 만들기 (0) 2022.10.22 [Unity] 점프 기능 구현 (0) 2022.10.21 [Unity] 점프 기능 구현을 위한 Visual Studio 환경세팅 (0) 2022.10.21