You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
986 B
49 lines
986 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using Cinemachine;
|
|
public class RotateButton : MonoBehaviour, IPointerDownHandler,IPointerEnterHandler,IPointerUpHandler,IPointerExitHandler
|
|
{
|
|
public CinemachineFreeLook cf;
|
|
public float speed=0.2f;
|
|
bool click = false;
|
|
bool enter = false;
|
|
public bool dir;
|
|
|
|
private void Start()
|
|
{
|
|
if (!dir)
|
|
{
|
|
speed *= -1;
|
|
}
|
|
}
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
click = true;
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
enter = true;
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
enter = false;
|
|
}
|
|
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
{
|
|
click = false;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (click&&enter)
|
|
{
|
|
cf.m_XAxis.Value += speed;
|
|
}
|
|
}
|
|
}
|