유니티

유니티 UI SetActive / enabled

SUGI_ 2023. 6. 30. 15:20

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