UI버튼 클릭시 Input.GetMouseButton사용 중지하는법

유니티 C# 2020. 11. 12. 15:23

출처: stackoverflow.com/questions/52763941/unity-how-to-stop-using-input-getmousebutton0-when-pressing-on-ui-button

 

Unity: How to stop using "Input.GetMouseButton(0)" when pressing on UI Button?

The player is a magican who can attack enemys with fireballs when pressing the left mouse button. The code i use is pretty simple (inside the Update function): if (Input.GetMouseButton(0) &&...

stackoverflow.com

EventSystem.current.IsPointerOverGameObject() 함수를 사용하여 체크 가능

 

if (Input.GetMouseButton(0) && canShoot && !EventSystem.current.IsPointerOverGameObject())