You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
893 B
C#
33 lines
893 B
C#
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;
|
|
|
|
}
|
|
}
|