浏览代码

refine raycast test for mobile

/add_hero_sample
Xingwei Zhu 3 年前
当前提交
c0a83343
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22
      AwesomeUIWidgets/Assets/Scripts/RaycastableScene/DragRotate.cs

22
AwesomeUIWidgets/Assets/Scripts/RaycastableScene/DragRotate.cs


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;
}

正在加载...
取消
保存