Search Unity

Question ScrollView value changed callback

Discussion in 'UI Toolkit' started by Hellfim, May 27, 2023.

  1. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    123
    Is there any way to handle scrollOffset's changes of the ScrollView?
    Would be REALLY good to have support for ChangeEvent<Vector2> (for example by having ScrollView implement INotifyValueChanged<Vector2>)

    I mean I can check wether scrollOffset did change if I use scheduler.Execute(ProcessScrollOffset).Until(() => false), but that seems like a bad practice.


    I would also like to mention here that PostPointerUpAnimation executes at static 30ms which produces jittery behaviour.
     
    StripeGuy likes this.
  2. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    248
    You can register value changes on the ScrollView's Scrollers instead.

    scrollView.horizontalScroller.slider.RegisterValueChangedCallback(...);

    scrollView.verticalScroller.slider.RegisterValueChangedCallback(...);


    I agree it would be nice to have a callback on the ScrollView directly. You can report a bug using `Help -> Report a Bug...` to get it in our pipeline. Same for the PostPointerUpAnimation animation interval.
     
    Last edited: May 31, 2023
    Hellfim likes this.
  3. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    123
    Whoah, nice. Somewhy I though that if I have disabled scrollers they don't produce events, my bad.

    Great to hear that! Please, check IN-42607

    Actually I already did this, but recieved a comment 'not enough information to reproduce'
    Please, check IN-42122 for that. I'm not sure what else should I do, hope you will be able to review that case and forward it to your internal pipeline.
     
    StripeGuy and griendeau_unity like this.