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. cozyurt_unity

    Jul 15, 2020 11:50

    Kedi Köpek Maması,Kedi Köpek Yaş Mamalar, Köpek Ödül Bisküviler,Kedi Köpek Aksesuarları,Kedi Kumu çeşitleri 100 TL üzeri kargo bedava,kredi kartlarına 12 taksit www.patilimama.com

  2. MrLucid72

    Sep 24, 2017 05:38

    still happens in 5.6.3p3 - NOT fixed

  3. grimmy

    Aug 24, 2017 15:45

    This is not fixed in 5.6.0

  4. grimmy

    Aug 24, 2017 15:44

    This is not fixed in 5.6.0

  5. Tech-Unity3d

    Jun 15, 2017 10:17

    Same issue. Big problem!!!

  6. 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. 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. TextusGames

    Apr 29, 2017 13:31

    That is not fixed in unity 5.6

  9. 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. hurleybird

    Apr 26, 2017 05:32

    Still happening in 5.6.0p2

Add comment

Log in to post comment

All about bugs

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