유니티[Unity]
유니티[Unity3D] 스크립트로 오브젝트 태그 변경하기
Dinosaur_Adventure를 만들던 중 게임 플레이 중간에 오브젝트의 태그를 변경해야하는 일이 생겼습니다. 스크립트로 아주 간단히 게임오브젝트의 태그를 변경할 수 있습니다. gameObject.tag = "태그명"; 와 같이 사용해주면 됩니다. using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChangeTag : MonoBehaviour { void Update() { if (Input.GetMouseButtonDown(0)) { Debug.Log("태그 변경!"); // 마우스 클릭을 알리기 위해 작성함 gameObject.tag = "Player"; } } } 위의 코드는 왼쪽 ..
2022. 1. 19. 21:42
최근댓글