반응형
간단히 구현해 보았음.
Code
using UnityEngine.UI;
using UnityEngine;
public class TouchInput : MonoBehaviour
{
public Text text1;
public Text text2;
public Text text3;
public Text text4;
private float lastTouchTime;
private const float doubleTouchDelay = 0.5f;
void Start() {
lastTouchTime = Time.time;
}
void Update()
{
if(Input.touchCount == 1) {
Touch touch = Input.GetTouch(0);
switch (touch.phase)
{
case TouchPhase.Began:
if(Time.time - lastTouchTime < doubleTouchDelay) // 더블터치 판정
{
text1.text = "TouchPhaes.Began (Double Touch)";
text4.text = "마지막입력: Double Touch";
}
else
{
text1.text = "TouchPhaes.Began";
text4.text = "마지막입력: 그냥터치";
}
break;
case TouchPhase.Moved:
text1.text = "TouchPhaes.Moved";
break;
case TouchPhase.Ended:
text1.text = "TouchPhaes.Ended";
text2.text = $"Time: {Time.time}";
lastTouchTime = Time.time;
break;
}
}
}
}
반응형
'Unity > Unity 리서치' 카테고리의 다른 글
Mobile Pinch Zoom (0) | 2021.06.09 |
---|---|
Mouse DoubleClick (0) | 2021.06.08 |
Mobile에서 터치 드래그 구현 (0) | 2021.06.06 |
에셋 번들 (Asset bundle) & 어드레서블(Addressables) (0) | 2021.06.05 |
[RTS Engine] Unit Attack 공격 딜레이 (0) | 2021.06.04 |