Search Issue Tracker

Fixed in 5.6.0

Votes

17

Found in

5.6.0b7

Issue ID

881819

Regression

Yes

Viewport content position values breaks to NaN value when changing Scroll Rect position (can not undo)

UI

-

Reproduction steps:
1. Open project attached (ScrollRectTest.zip).
2. Open scene "test".
3. Press on Scroll Rect (in Canvas).
4. Drag it by X.

Expected result: Scroll Rect moves with all its content.
Actual result: Content (Scroll Rect -> Viewport) rect transform position breaks (becomes NaN) and unable to undo it.

Reproduced on: 5.6.0b2, 5.6.0b7, 5.6.0b9.
Works fine in: 5.5.1p4, 5.6.0b1.
Regression introduced in: 5.6.0b2.

Comments (24)

  1. 1169f1593c85c87d034c07bc03f14917?d=mm

    colamrager

    May 17, 2019 11:53

    If you are good content maker and know everything about it, your content always takes high position, you should visit <a href="https://vip-writers.com/">https://vip-writers.com/</a> . Than you will not have any troubles.

  2. 9746878fd170891307bb46706af297a8?d=mm

    MrLucid72

    Sep 24, 2017 05:38

    still happens in 5.6.3p3 - NOT fixed

  3. D886075fb7dc3635062213e106e4792f?d=mm

    grimmy

    Aug 24, 2017 15:45

    This is not fixed in 5.6.0

  4. D886075fb7dc3635062213e106e4792f?d=mm

    grimmy

    Aug 24, 2017 15:44

    This is not fixed in 5.6.0

  5. Fefe7d4fef51ddba40ce1d82aed6cd91?d=mm

    Tech-Unity3d

    Jun 15, 2017 10:17

    Same issue. Big problem!!!

  6. Db2738da0b942b57c05f74a50e1703f6?d=mm

    radiowaves

    May 08, 2017 14:44

    After spending hours of rebuilding my UI elements, it went crazy again. Sometimes the position values turn to NaN, sometimes overly large numbers when set to 0. It feels like the whole UI system is hanging on a thin piece of thread ready to snap at any moment.

  7. Db2738da0b942b57c05f74a50e1703f6?d=mm

    radiowaves

    May 08, 2017 12:02

    Happening in Unity 5.6.0f3, project broken, scroll rects unusable, and I have quite many of them in my project, half the game is broken because of that.

  8. Abcf103768e747515c8a3a2733b4ccf1?d=mm

    TextusGames

    Apr 29, 2017 13:31

    That is not fixed in unity 5.6

  9. 4d1ceadaae8f7b8f408d816475dee377?d=mm

    Chris-Android

    Apr 26, 2017 22:50

    Update to the previous comment I made. Resolved issue whereby inactive objects weren't fixed.
    Hope this will help.

    #if UNITY_EDITOR && UNITY_5_6
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEditor;
    using UnityEngine.UI;
    using UnityEditor.SceneManagement;

    public class ScrollRectNANEditor : EditorWindow
    {
    static ScrollRectNANEditor _window;

    [MenuItem("ScrollRect (5.6) Bug Fixer/Open Window #F9")]
    public static void Open()
    {
    if (_window != null)
    EditorWindow.GetWindow<ScrollRectNANEditor>().Close();
    //Show existing window instance. If one doesn't exist, make one.
    _window = EditorWindow.GetWindow<ScrollRectNANEditor>("NAN Fixer", true, typeof(SceneView)) as ScrollRectNANEditor;
    }

    [MenuItem("ScrollRect (5.6) Bug Fixer/Fix Now")]
    public static void FixNow()
    {
    Open();
    _window.FixBug();
    }

    void OnGUI()
    {
    EditorGUILayout.BeginVertical();
    GUILayout.FlexibleSpace();
    if (GUILayout.Button ("Fix Now", EditorStyles.toolbarButton))
    FixBug();
    GUILayout.FlexibleSpace();
    EditorGUILayout.EndVertical();
    }

    void FixBug()
    {
    if (_window == null)
    {
    FixNow();
    return;
    }

    ScrollRect[] scrolls = FindObjectsOfTypeAll<ScrollRect>();
    //ScrollRect[] scrolls = FindObjectsOfType(typeof(ScrollRect)) as ScrollRect[]; // Doesn't allow for inactive gameobjects.
    if (scrolls == null || scrolls.Length == 0)
    {
    if (_window != null)
    _window.ShowNotification(new GUIContent("No ScrollRects have been found."));
    }
    else
    {
    for (int i = 0; i < scrolls.Length; i++)
    scrolls[i].enabled = false;

    for (int i = 0; i < scrolls.Length; i++)
    {
    ScrollRect scroll = scrolls[i];
    if (scroll.movementType == ScrollRect.MovementType.Clamped)
    {
    scroll.movementType = ScrollRect.MovementType.Elastic;
    scroll.elasticity = 0;
    }
    if (scroll.content != null)
    scroll.content.anchoredPosition = FixIfNaN(scroll.content.anchoredPosition);
    }

    for (int i = 0; i < scrolls.Length; i++)
    scrolls[i].enabled = true;

    if (_window != null)
    _window.ShowNotification(new GUIContent(scrolls.Length + " instances have been successfully fixed ;)"));
    }
    }

    public static T[] FindObjectsOfTypeAll<T>()
    {
    List<T> results = new List<T>();
    for(int i = 0; i< EditorSceneManager.sceneCount; i++)
    {
    var s = EditorSceneManager.GetSceneAt(i);
    if (s.isLoaded)
    {
    var allGameObjects = s.GetRootGameObjects();
    for (int j = 0; j < allGameObjects.Length; j++)
    {
    var go = allGameObjects[j];
    results.AddRange(go.GetComponentsInChildren<T>(true));
    }
    }
    }
    return results.ToArray();
    }

    Vector2 FixIfNaN(Vector2 v)
    {
    v.x = v.x.FixIfNaN();
    v.y = v.y.FixIfNaN();
    return v;
    }

    Vector3 FixIfNaN(Vector3 v)
    {
    v.x = v.x.FixIfNaN();
    v.y = v.y.FixIfNaN();
    v.z = v.z.FixIfNaN();
    return v;
    }
    }
    #endif

  10. 33c40919b6f814e5f07bacfd50e48d20?d=mm

    hurleybird

    Apr 26, 2017 05:32

    Still happening in 5.6.0p2

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.