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().Drag += DragEvent; yg.GetComponent().DragEnd += DragEnd; } public void OnDrag(PointerEventData eventData)//ÆÁÄ»Òƶ¯ { Player.GetComponent().HandleViewSwipe(); } public void DragEvent(float x, float y, PointerEventData eventData)//Ò¡¸ËÒƶ¯ { horizontal = x; vertical = y; } public void DragEnd()//Ò¡¸ËÒƶ¯ { horizontal = 0; vertical = 0; } public float horizontal = 0; public float vertical = 0; public void Update() { if (horizontal != 0 || vertical != 0) Player.GetComponent().HandleJoystickControl(horizontal, vertical); } }