|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.EventSystems; |
|
|
|
using UInput = UnityEngine.Input; |
|
|
|
|
|
|
return new Vector2(UInput.mousePosition.x, UInput.mousePosition.y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static bool IsPointerOverUIObject(float x, float y) { |
|
|
|
PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current); |
|
|
|
eventDataCurrentPosition.position = new Vector2(x, y); |
|
|
|
List<RaycastResult> results = new List<RaycastResult>(); |
|
|
|
EventSystem.current.RaycastAll(eventDataCurrentPosition, results); |
|
|
|
return results.Count > 0; |
|
|
|
} |
|
|
|
|
|
|
|
void OnMouseDown() |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach (Touch touch in UInput.touches) |
|
|
|
{ |
|
|
|
if (touch.phase == TouchPhase.Began) |
|
|
|
{ |
|
|
|
int id = touch.fingerId; |
|
|
|
if (IsPointerOverUIObject(touch.position.x, touch.position.y)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_lastPosition = mousePosition; |
|
|
|
} |
|
|
|