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. 4d1ceadaae8f7b8f408d816475dee377?d=mm

    Chris-Android

    Apr 21, 2017 22:56

    I tried the 'Clamped' option and for some odd reason was unsuccessful....so I created this script. I hope it'll help those who are also in the same position as me.

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

    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>("", true, typeof(SceneView)) as ScrollRectNANEditor;
    }

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

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

    void FixBug()
    {
    ScrollRect[] scrolls = FindObjectsOfType(typeof(ScrollRect)) as ScrollRect[];
    for (int i = 0; i < scrolls.Length; i++)
    {
    ScrollRect scroll = scrolls[i];
    scroll.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++)
    {
    ScrollRect scroll = scrolls[i];
    scroll.enabled = true;
    }

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

    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

  2. 58ddee8a3c578b42fc7941afec2c72b5?d=mm

    Genebris

    Apr 18, 2017 19:16

    Thank you, PhaneV. Changing from clamped to elastic solved it.

  3. 691b44e2a7a80d9b1890ac4a3ae33dfe?d=mm

    guitarburner

    Apr 14, 2017 15:33

    This happens to me in the current version 5.6.0f3.
    The solution to avoid this till they fix this bug is the one that PHANEV said:

    This issue stopped reproducing after I changed the Movement Type of the scroll rect to "Elastic". Was previously using "Clamped".

  4. 462a16c9e9be677d620513f3143441a6?d=mm

    Ederic

    Apr 13, 2017 09:57

    We are having the same problem, scroll rect value goes to NAN when we move it. In 5.6.0f3

  5. 8df7469bcf2f3c537f8fe89e44f75231?d=mm

    zkw

    Apr 11, 2017 09:16

    So is there gonna be a fix for 5.6 too or will this be only fixed in 2017? o.O

  6. 9746878fd170891307bb46706af297a8?d=mm

    MrLucid72

    Apr 09, 2017 15:44

    Really messes up our UI in 5.6f3

  7. 79b1cf5f5320cd93dae6a7d1fc4974ab?d=mm

    PhaneV

    Apr 07, 2017 20:12

    Further on:
    This issue stopped reproducing after I changed the Movement Type of the scroll rect to "Elastic". Was previously using "Clamped".

    I tried this after finding this bug here, which might be related (?) :
    https://issuetracker.unity3d.com/issues/rect-transform-values-are-set-to-nan-when-decreasing-the-height-of-the-content-game-object-in-scroll-view

  8. 79b1cf5f5320cd93dae6a7d1fc4974ab?d=mm

    PhaneV

    Apr 07, 2017 20:08

    Happens in 5.6.0f2 Personal.
    Thanks @ Egproject, otherwise I would've updated to try on it too.

  9. 2ff43146eba08675e595fe2ea85489ff?d=mm

    uzihead

    Apr 07, 2017 16:09

    The issue is still present in 5.6.0f3 Plus. All my drop downs got broken with the update, unfortunately. Scroll rect still unusable unless ready to redo it 100 times until you get lucky.

  10. 908c0c1508167ed52d866ba072839352?d=mm

    EGProject

    Apr 07, 2017 08:48

    Reproduces with 5.6.0f3 Personal

All about bugs

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