Canvas管理Panel的点击事件
private void Update()
{
if(Input.touchCount > 0)
{
TouchDeal(Input.mousePosition);
}
}
//手指点击之间
处理
void PointrEvent()
{
foreach (Touch touch in Input.touches)
{
TouchDeal(touch.position);
}
}
//碰撞到的UI判断
void TouchDeal(Vector2 touchPosition)
{
PointerEventData pointer = new PointerEventData(EventSystem.current);
pointer.position = new Vector2(touchPosition.x, touchPosition.y);
List<RaycastResult> results = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointer, results);
foreach (RaycastResult result in results)
{
if (JoyStick_Panel == result.gameObject)
{
//处理摇杆
}
else if(SkillButton_Panel)
{
//处理技能
}
else
{
}
}
}