본문 바로가기
유니티

유니티 UI SetActive / enabled

by SUGI_ 2023. 6. 30.

GameObject.SetActive : 오브젝트를 활성화 및 비활성화

오브젝트를 비활성화 시키면 오브젝트 자체가 씬, 게임뷰에서 사라지고 작동하지 않음

 

Behaviour.enabled : 오브젝트에 추가되어 있는 컴포넌트를 활성화 및 비활성화

특정 기능을 만들 때 지정한 컴포넌트만 비활성화 시켜서 기능을 잠시 정지시키는 용도로 사용가능

 

                //부모 게임오브젝트 비활성화
                startText.gameObject.SetActive(false);
                
                //컴포넌트 비활성화
                startText.enabled = false;

                //비활성화
                startPanel.SetActive(false);

 

https://artiper.tistory.com/106

 

[Unity] SetActive와 enabled

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.

artiper.tistory.com

 

728x90

'유니티' 카테고리의 다른 글

메소드 오버라이드  (0) 2023.07.03
유니티 [Texture , Materiall]  (0) 2023.06.30
6/30 [ScoreManager(싱글톤) , 코루틴]  (0) 2023.06.30
6/30 C# 클래스 상속  (0) 2023.06.30
6/29 [Invoke, OnBeacmeInvisible(), SoundManger(싱글톤)]  (0) 2023.06.29