37 lines
761 B
C#
37 lines
761 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.UI;
|
|
|
|
public class ScroolByPad : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
|
|
{
|
|
public Texture2D cursorTexture;
|
|
|
|
private ScrollRect scrollRect;
|
|
|
|
private bool isOnScroll;
|
|
|
|
private void Start()
|
|
{
|
|
scrollRect = GetComponent<ScrollRect>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)scrollRect && isOnScroll && Gamepad.current != null)
|
|
{
|
|
scrollRect.verticalNormalizedPosition += Time.unscaledDeltaTime * Gamepad.current.rightStick.ReadValue().y;
|
|
}
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
isOnScroll = true;
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
isOnScroll = false;
|
|
}
|
|
}
|