2024-11-19 23:18:17 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
|
|
|
|
public class DragTheScreen : MonoBehaviour, IDragHandler
|
|
|
|
|
{
|
|
|
|
|
public GameObject yg;
|
|
|
|
|
public GameObject Player;
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
yg.GetComponent<Joystick>().Drag += DragEvent;
|
|
|
|
|
yg.GetComponent<Joystick>().DragEnd += DragEnd;
|
|
|
|
|
}
|
|
|
|
|
public void OnDrag(PointerEventData eventData)//<2F><>Ļ<EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
{
|
2024-11-20 14:37:08 +08:00
|
|
|
|
Player.GetComponent<PlayerMovement_Jpystick>().HandleViewSwipe();
|
2024-11-19 23:18:17 +08:00
|
|
|
|
}
|
2024-11-20 14:37:08 +08:00
|
|
|
|
public void DragEvent(float x, float y, PointerEventData eventData)//ҡ<><D2A1><EFBFBD>ƶ<EFBFBD>
|
2024-11-19 23:18:17 +08:00
|
|
|
|
{
|
2024-11-20 14:37:08 +08:00
|
|
|
|
|
|
|
|
|
horizontal = x;
|
|
|
|
|
vertical = y;
|
2024-11-19 23:18:17 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DragEnd()//ҡ<><D2A1><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
horizontal = 0;
|
|
|
|
|
vertical = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float horizontal = 0;
|
|
|
|
|
public float vertical = 0;
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
if (horizontal != 0 || vertical != 0) Player.GetComponent<PlayerMovement_Jpystick>().HandleJoystickControl(horizontal, vertical);
|
|
|
|
|
}
|
|
|
|
|
}
|