using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class DragTheScreen : MonoBehaviour, IDragHandler { public GameObject yg; public GameObject Player; public CameraControl CameraControl; private bool isscanmove = true; private void Start() { yg.GetComponent().Drag += DragEvent; yg.GetComponent().DragEnd += DragEnd; } public void OnDrag(PointerEventData eventData)//ÆÁÄ»Òƶ¯ { if (isscanmove) { 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 (CameraControl.joystickController.joystickInput.magnitude > 0) { isscanmove = false; if (horizontal != 0 || vertical != 0) Player.GetComponent().HandleJoystickControl2(horizontal, vertical); } else { isscanmove = true; if (horizontal != 0 || vertical != 0) Player.GetComponent().HandleJoystickControl(horizontal, vertical); } } }