Skip to content

Instantly share code, notes, and snippets.

@emredesu
emredesu / ScrollRectAutoScroll.cs
Last active June 18, 2024 07:35 — forked from mandarinx/ScrollRectAutoScroll.cs
Re-written for the new input system. Also uses unscaledDeltaTime for use in pause menus, and doesn't do anything if the platform is a mobile platform with no gamepads connected.
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.InputSystem;
[RequireComponent(typeof(ScrollRect))]
public class ScrollRectAutoScroll : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
public float scrollSpeed = 10f;
private bool mouseOver = false;