마우스 [유니티 매뉴얼] UI Button 계속 누르고 있는 상태 확인 2021. 5. 11. 1. UI Button에 Event Trigger를 추가 한 뒤 Add New Event를 클릭하여, Pointer Down과 Pointer Up을 클릭합니다. 2. 스크립트를 만듭니다. using UnityEngine; public class UiController : MonoBehaviour { public bool m_IsButtonDowning; void Update() { if(m_IsButtonDowning) { // 여기에 할 일을 넣으면 됩니다. } } public void PointerDown() { m_IsButtonDowning = true; } public void PointerUp() { m_IsButtonDowning = false; } } 3. 적당한 게임 오브젝트에 위 스크립.. [유니티 스크립트 소스] 마우스(Mouse) 관련 2020. 3. 24. 1. Input 클래스 1.1 마우스 버튼 (1) 함수 함수 설명 bool GetMouseButtonDown (int button); 마우스 버튼을 누른 프레임 동안 true를 반환 bool GetMouseButton (int button); 마우스 버튼이 눌렸는지 여부를 반환 bool GetMouseButtonUp (int button); 마우스 버튼에서 손을 뗏을 때 true를 반환 (2) 매개 변수 (int button) 매개변수 설명 0 마우스 왼쪽 버튼 1 마우스 오른쪽 버튼 2 마우스 휠 버튼 3 ~ 6 마우스 추가 버튼 (3) 데모 using UnityEngine; public class DemoMouseInputClass : MonoBehaviour { void Update() { if (.. [유니티 스크립트 소스] 마우스로 게임오브젝트 Drag로 이동시키기 2020. 3. 15. 1. 게임오브젝트 설정 (1) 게임오브젝트에 Collider 추가 (2) 게임오브젝트에 Rigidbody 추가 (3) Rigidbody에 Use Gravity 끄기 2. 소스 using UnityEngine; public class DragGameobject : MonoBehaviour { private Vector3 m_Offset; private float m_ZCoord; void OnMouseDown() { m_ZCoord = Camera.main.WorldToScreenPoint(gameObject.transform.position).z; m_Offset = gameObject.transform.position - GetMouseWorldPosition(); } void OnMouseDrag().. 이전 1 다음