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)
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)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “Look Dev” window restored from previous HDRP project causes errors in newly created URP project
- Shader Variant creation window gets stretched out when canceling
- Validation message "Profile name is unsupported" is unclear and does not provide information on what is wrong
- Enabling Override Variant Limit toggle Warning Threshold value gets set to 8
- Missing space in Shader Graph project settings
MrLucid72
Sep 24, 2017 05:38
still happens in 5.6.3p3 - NOT fixed
grimmy
Aug 24, 2017 15:45
This is not fixed in 5.6.0
grimmy
Aug 24, 2017 15:44
This is not fixed in 5.6.0
Tech-Unity3d
Jun 15, 2017 10:17
Same issue. Big problem!!!
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.
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.
TextusGames
Apr 29, 2017 13:31
That is not fixed in unity 5.6
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
hurleybird
Apr 26, 2017 05:32
Still happening in 5.6.0p2
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