백지부터 시작하는 이세계 코딩 생활

OnMouseDrag() 본문

백지부터 시작하는 이세계 유니티 생활 since 2020

OnMouseDrag()

조아덕 2021. 1. 29. 15:55
OnMouseDrag

마우스 포인터를 활용, 해당 오브젝트를 선택한 상태에서 움직일 수 있게 한다.

blog.danggun.net/4384

 

OnMouseDrag는 사용자가 GUIElement 또는 Collider를 클릭하고 마우스 버튼을 계속 누르고 있는 경우에 호출됩니다.

마우스 버튼이 눌리고 있는 동안에, 매 프레임마다 호출됩니다.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Renderer rend;
    void Start() {
        rend = GetComponent<Renderer>();
    }
    void OnMouseDrag() {
        rend.material.color -= Color.white * Time.deltaTime;
    }
}

 


Ref.

2D 오브젝트 드래그 & 드랍

1 www.youtube.com/watch?v=BGr-7GZJNXg

 

*** 2D 오브젝트 드래그 & 드랍 #2

2 www.youtube.com/watch?v=p7akGCRgBLA

 

3 www.youtube.com/watch?v=55TBhlOt_U8

 

 

3D 오브젝트 드래그 & 드랍

4 blog.danggun.net/4384

 

[Unity 5] 오브젝트 드레그(Drag) 하기

전에 4.x버전용 드래그를 구현한 적이 있습니다. (참고 : [Unity 4] 오브젝트 드래그 하기 ) 그런데 5.x용 자료를 보다 보니 드래그 관련 이벤트가 있군요. 언제 생긴 건지 모르겠지만 이것을 이용하

blog.danggun.net

 

5 docs.unity3d.com/kr/530/ScriptReference/MonoBehaviour.OnMouseDrag.html

 

Unity - 스크립팅 API: MonoBehaviour.OnMouseDrag()

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. 닫기

docs.unity3d.com

'백지부터 시작하는 이세계 유니티 생활 since 2020' 카테고리의 다른 글

Resources  (0) 2021.02.10
OnMouse~ 이벤트  (0) 2021.01.30
ScrollView  (0) 2021.01.20
논리연산자 사용법 차이  (0) 2021.01.19
lineRenderer.SetPosition  (0) 2021.01.15
Comments