using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class TWS_CharacterPreviewerJoystickController : MonoBehaviour, IDragHandler { private float lastX_Val = 0; private int direction = 1; private Vector2 currentPointerPosition; public RectTransform containerRect; public void OnDrag(PointerEventData eventData) { RectTransformUtility.ScreenPointToLocalPointInRectangle(containerRect, eventData.position, eventData.pressEventCamera, out currentPointerPosition); if (currentPointerPosition.x > lastX_Val) { direction = -1; } else if (currentPointerPosition.x < lastX_Val) { direction = 1; } TWS_Delegates.TriggerLookRotationHappenedFromJoystick(direction); lastX_Val = currentPointerPosition.x; } }