일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 픽셀 아트
- TOOL
- 자원순환보증금관리센터
- 연습
- pixel art
- 기초
- 장학팀
- 인디게임 개발
- menu
- COSMO
- 애니메이션
- 포토샵
- 스마일게이트
- 드로잉
- 서포터즈
- 모작
- 드로잉 연습
- layer
- 반환원정대
- 개발
- 에이세프라이트
- 채색
- Aseprite
- 도트
- 도트공부
- Pixelart
- 멋쟁이사자처럼
- 픽셀아트
- 노하우
- photoshop
- Today
- Total
소소한 나의 하루들
TextMeshPro 활성화 /비활성화 (ft. SetActive() vs .enabled) 본문
https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html
Unity - Scripting API: GameObject.SetActive
A GameObject may be inactive because a parent is not active. In that case, calling SetActive will not activate it, but only set the local state of the GameObject, which you can check using GameObject.activeSelf. Unity can then use this state when all paren
docs.unity3d.com
https://docs.unity3d.com/ScriptReference/Behaviour-enabled.html
Unity - Scripting API: Behaviour.enabled
Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close
docs.unity3d.com
GameObject.SetActive() : 오브젝트를 활성화/ 비활성화 하는 역할을 한다. 오브젝트를 비활성화시키면 오브젝트가 Scene, Game 창에서 사라진다. (비활성화)
※부모 오브젝트가 활성화되어있을 때 이 SetAvtive()를 사용할 수 있다.
Behaviour.enabled : 오브젝트에 추가되어있는 컴포넌트를 활성화 / 비활성화 하는 역할을 한다. 특정 기능을 만들 때 지정한 컴포넌트만 비활성화시켜서 기능을 정지시킬 수 있다.
public bool activeSelf;
GameObject.activeSelf : GameObject의 local active state이다. 현재 Object가 활성화되어있는지 여부를 확인할 수 있다. (읽기전용)
https://forum.unity.com/threads/how-can-you-enable-disable-textmeshpro-text-in-a-script.678919/
How can you enable/disable TextMeshPro text in a script?
Like the title asks... Regular text can be enabled using (placetexthere).enabled = true, but how can you do it for TextMesh Pro text?
forum.unity.com
그런데 TextMeshPro는 동일한 개체에 MeshRenderer와 함께 제공된다. 따라서 meshRenderer.enabled = true/false로 활성화 여부를 결정할 수 있고 TextMeshProUGUI 구성요소는 T=textMeshProUGUI.enabled = true/false를 사용하여 활성화여부를 결정할 수 있다. (예시: Button UI 부모클래스 하위의 TextMeshPro UI 자식 클래스)
아마도 부모 클래스를 먼저 .SetActive()를 이용해서 활성화/비활성화 시켜줘야 자식클래스를 .enabled로 활성화/비활성화를 결정할 수 있는 것 같다.
'개발 > 유니티' 카테고리의 다른 글
2d 플랫포머(최종) - 피드백 추가 및 개선사항 (0) | 2024.01.27 |
---|---|
유니티 코루틴(Coroutine) / 서브루틴(Sub Routine) +α (0) | 2024.01.27 |
유니티 TextMeshPro(TMP) UI 래퍼런스 할당 (0) | 2024.01.26 |
2d 플랫포머(8) - 스테이지를 넘나드는 게임 완성하기 (0) | 2024.01.25 |
2d 플랫포머(7) - 플레이어 피격 이벤트 구현하기 (0) | 2024.01.24 |