public class PaperButton : MonoBehaviour
{
private GameObject PaperList;
void Start()
{
PaperList = GameObject.Find("PaperList");
}
void Update()
{
if (Input.GetMouseButton(0))
{
if (PaperList) {
PaperList.SetActive(false);
}
else Debug.Log("PaperList없엉없엉");
}
if (Input.GetMouseButton(0))
{
Debug.Log("TOuch End");
}
}
}
위와 같이 전역 변수 선언을 하고, start에서 GameObject.Find를 해주었는지 잘 확인해봐야 한다. 물론 Update에서 GameObject.Find를 해도 되지만, update에서 계속 object를 find하는건 비효율적이기에 start메소드에서 호출한다.
'시궁창부터 시작하는 게임개발 > Unity 에러해결' 카테고리의 다른 글
[Unity error] instantiate함수 사용해도 게임뷰에 안보일 때 (0) | 2021.04.06 |
---|---|
[Unity error] Debug 창을 사용할 수 없는 경우 (0) | 2021.04.05 |
[Unity] VsCode로 연동 시 intellisense 작동안함. (0) | 2021.03.08 |
유니티 콜라보레이터 사용법 (0) | 2021.01.29 |
유니티 애니메이션 창의 샘플레이트 안보일 때 (0) | 2021.01.27 |