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(); } 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; } }