Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question ScrollRect incorrect work in UWP build

Discussion in 'UGUI & TextMesh Pro' started by Mihalchev, May 1, 2024.

  1. Mihalchev

    Mihalchev

    Joined:
    Jul 15, 2020
    Posts:
    5
    For clarity, the background for ScrollRect and Content was colored.
    white is scroll
    green is content

    in the popup near the title there is debugging text
    Cbounds - bound content of the scroll object.
    and by some magic he is x size miniature. Although, as you can see from the screenshots, it is of normal size (green)
    There is a canvas scaler on the top canvas. The child Content object has a ContentSizeFilter with Preferred Size for Hor and Vert

    At the top of the Popup next to the title there is a debug text, where VBounds is View Bounds, and CBounds is content Bounds. I took the code from ScrollRect.cs

    Code from Unity ScrollRect.cs:

    Code (CSharp):
    1. protected void UpdateBounds()
    2.         {
    3.             m_ViewBounds = new Bounds(viewRect.rect.center, viewRect.rect.size);
    4.             m_ContentBounds = GetBounds();
    5.         }
    6.  
    7. private Bounds GetBounds()
    8.         {
    9.             if (m_Content == null)
    10.                 return new Bounds();
    11.             m_Content.GetWorldCorners(m_Corners);
    12.             var viewWorldToLocalMatrix = viewRect.worldToLocalMatrix;
    13.             return InternalGetBounds(m_Corners, ref viewWorldToLocalMatrix);
    14.         }
    15.  
    16.         internal static Bounds InternalGetBounds(Vector3[] corners, ref Matrix4x4 viewWorldToLocalMatrix)
    17.         {
    18.             var vMin = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
    19.             var vMax = new Vector3(float.MinValue, float.MinValue, float.MinValue);
    20.  
    21.             for (int j = 0; j < 4; j++)
    22.             {
    23.                 Vector3 v = viewWorldToLocalMatrix.MultiplyPoint3x4(corners[j]);
    24.                 vMin = Vector3.Min(v, vMin);
    25.                 vMax = Vector3.Max(v, vMax);
    26.             }
    27.  
    28.             var bounds = new Bounds(vMin, Vector3.zero);
    29.             bounds.Encapsulate(vMax);
    30.             return bounds;
    31.         }
    photo_2024-05-01_10-30-07.jpg
    (1 pic.) (correct) - unity, android, ios
    photo_2024-05-01_10-30-12.jpg
    (2 pic.)(incorrect) - uwp

    On the previous version of Unity it was ok
    Was 2020.3.33f1
    Became 2022.3.19f
     
    Last edited: May 20, 2024
  2. Mihalchev

    Mihalchev

    Joined:
    Jul 15, 2020
    Posts:
    5
    Here's another joke.
    I added a standard scroll on top, added only grid and contentSizeFilter to the content as on the original one. And I hung up a script that copies objects from the original.

    For some reason it only bends to the left and when you get to the right edge it cuts out the speedroll _-_

    In the original I suspect it's the same,
    it’s just that the script immediately spins it to the end

    Attach video
    Build:
    https://gyazo.com/c007a6ba9b5af6e76e08e55313867975

    Unity:
    https://gyazo.com/d60e04f7cb1497345165ade4f85742a0
     
  3. Mihalchev

    Mihalchev

    Joined:
    Jul 15, 2020
    Posts:
    5
    Last edited: May 1, 2024
  4. Mihalchev

    Mihalchev

    Joined:
    Jul 15, 2020
    Posts:
    5
    I added buildFlag BuildOptions.AllowDebugging;
    Thanks to this, a Debug window appears in the build before the unit splash (at the very start of the project before the first update).
    And it fixes scrolling!!!!!!
    you remove the flag and this problem appears again
     

    Attached Files: