Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Error in scroll view when drop frame

Discussion in 'Scripting' started by Hoya127, Mar 29, 2022.

  1. Hoya127

    Hoya127

    Joined:
    Dec 18, 2021
    Posts:
    34
    When the frame is dropped, the scroll coordinates will be NaN.

    Frame drop occurs while scrolling
    The value of Time.unscaledDeltaTime will be 0.

    It was confirmed in the following way.

    private void LateUpdate()
    {
    float deltaTime = Time.unscaledDeltaTime;
    if (deltaTime == 0)
    {
    ScrollRect scrollRect = GetComponentInParent<ScrollRect>();
    Debug.Log(string.Format("anchoredPosition....{0},{1}", scrollRect.content.anchoredPosition.x, scrollRect.content.anchoredPosition.y));
    }
    }

    anchoredPosition....0,5715.194
    anchoredPosition....0,NaN
    anchoredPosition....0,NaN

    My Unity version is 2021.1.271f.

    I'm looking for advice from someone who solved this.

    Thank you in advance.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    How many entries are in your scrollrect?
    Honestly, if it's a lot, I would look into a recycling scroll rect that uses object pooling.
     
  3. Hoya127

    Hoya127

    Joined:
    Dec 18, 2021
    Posts:
    34
    This happens with both reuse scrolling and regular scrolling.
    It also happens that scrollrect has 10 counts.
    There doesn't seem to be any problem with the count and scrolling method.
    Expected to be a bug in scrollrect.
     
  4. realragnvaldr

    realragnvaldr

    Joined:
    Jul 21, 2019
    Posts:
    40
    See here for a thread on the same problem (and a simple solution)