본문 바로가기

유니티 게임 개발

(5)
텍스트 ContentSize 스크립트 public class ContentSizeFitter : MonoBehaviour { [SerializeField] private TextMeshProUGUI m_TMProUGUI; public TextMeshProUGUI TextMeshPro { get { if (m_TMProUGUI == null && transform.GetComponentInChildren()) { m_TMProUGUI = transform.GetComponentInChildren(); m_TMPRectTransform = m_TMProUGUI.rectTransform; } return m_TMProUGUI; } } protected RectTransform m_RectTransform; public RectTransform r..
다중 유닛 중 개별 유닛 선택 (마우스 클릭)
유니티 애니메이션 (Mixamo) 애니메이션 다운로드 https://www.mixamo.com Unity, No character 로 다운받아서 유니티에 드래그앤 드롭 Rig -> Humanoid 로 바꾸기 Animation -> 이름 바꾸기 가능 Loop Time 체크 (필요하다면) Root Transform Rotation -> Based Upon -> Original 로 바꿔서 방향 맞는지 확인 Animation Clip -> Unity Model 로 애니메이션 확인 가능 Animator 옵션 Apply Root Motion : 애니메이션안에 이동하는 (좌표는 그대로지만, 모델링이 앞으로 나가는) 경우 제거 애니메이션 ReadOnly 는 복붙해서 수정할 수 있음 총 위치는 레코드 해서 애니메이션마다 바꿔주자 Animator Cond..
마우스, Unit Movement / Selection 카메라 뷰 변경 단축키 컨트롤 + 시프트 + F 기본 이동 로직 Distance 로 거리 체크 targetPosition 과 transform.position 변수 사용 moveDirection 구해서 그 방향으로 이동시키기 public class Unit : MonoBehaviour { private Vector3 targetPosition; float moveSpeed = 5f; float stoppingDistance = .1f; private void Update() { if(Vector3.Distance(targetPosition, transform.position) > stoppingDistance) { Vector3 moveDirection = (targetPosition - transfor..
Unity Project Setup 고려 사항 유니티 버전 : 2021.3.21f1 LTS : Long Term Support 3D (URP) 3D 3D URP : 선택 URP Template 렌더 파이프라인 Built-in Render pipeline (기존, 레거시) Universal Render pipeline (지금 선택한 것) High Definition Render pipeline (좀 과한 것) Package Manager / Universal RP 인스톨 확인 Project Settings / Graphics / URP Global Settings 에서 설정 및 변경 가능 에셋 다운로드 (모델링) -> Window / Rendering / Render Pipeline Converter / Built-in to URP 선택 Post-Pr..