Author Topic: Scroll View check if scrolling  (Read 6955 times)

callski

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 9
    • View Profile
Scroll View check if scrolling
« on: December 19, 2014, 11:43:55 AM »
Hello Everyone!
     What is the best way to tell if a scroll panel has finished scrolling? I need to fire an event when the panel is not moving. Thank you for your time!

callski

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Scroll View check if scrolling
« Reply #1 on: December 19, 2014, 02:09:59 PM »
So what I've done is created a script to see if the gameobject is moving or not. This is extremely inefficient but I need make sure the panel is not scrolling before I fire an event. Below is my script. I would appreciate any feedback if someone has a better way on telling if a panel is being scrolled.

<code>
using UnityEngine;
using System.Collections;

public class MovementCheck : MonoBehaviour
{
    public bool IsMoving;
    private float _lastY = 0;

    void Update()
    {
        if (transform.position.y != _lastY)
        {
            IsMoving = true;
            _lastY = transform.position.y;
        }
        else
        {
            IsMoving = false;
        }
    }
}
</code>

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View check if scrolling
« Reply #2 on: December 19, 2014, 06:20:30 PM »
UIScrollView.onDragFinished
UIScrollview.onStoppedMoving