dpy
New Member
Posts: 7
|
Post by dpy on Feb 13, 2021 1:11:31 GMT
Hi, I've come across an issue when using "Scale with Screen Size" canvas setting. The issue is demonstrated using demo 08: i.imgur.com/ZiqwHCK.mp4 As you can see, it doesn't scroll to the end sometimes. Then it's delayed through multiple frames before the new rows can be actually seen. Can this be avoided somehow?
|
|
|
Post by echo17 on Feb 13, 2021 11:13:50 GMT
I'm not seeing this in my version of Unity (2020.1.6f1) / EnhancedScroller (2.27.1). My guess is that there was a bug in Unity that they fixed in a later release. imgur.com/a/G1ke2DX
|
|
dpy
New Member
Posts: 7
|
Post by dpy on Feb 14, 2021 12:02:32 GMT
I'm not seeing this in my version of Unity (2020.1.6f1) / EnhancedScroller (2.27.1). My guess is that there was a bug in Unity that they fixed in a later release. imgur.com/a/G1ke2DXIt seems to be a combination of the Game window resolution and the canvas resolution. Please try changing the size of the game window to something like 627x325 when canvas is 800x600: i.imgur.com/89MZcTS.jpgI've downloaded 2020.2.4f1 and still seeing the same behaviour (ES 2.27.1): i.imgur.com/l6U3cym.gif
|
|
|
Post by echo17 on Feb 15, 2021 11:35:38 GMT
Odd, I'm still not seeing the issue on my setup. I'm on Mac OS 11.1. It may be a platform / OS issue that Unity will have to resolve. I would suggest filing a bug report with their support team. I would recommend going through the editor menu "Help > Report a Bug..." since that method allows you to submit a project for their inspection. imgur.com/a/dQgYlOC
|
|
dpy
New Member
Posts: 7
|
Post by dpy on Feb 19, 2021 18:39:32 GMT
Odd, I'm still not seeing the issue on my setup. I'm on Mac OS 11.1. It may be a platform / OS issue that Unity will have to resolve. I would suggest filing a bug report with their support team. I would recommend going through the editor menu "Help > Report a Bug..." since that method allows you to submit a project for their inspection. imgur.com/a/dQgYlOCHave you tried changing the resolution by dragging the window border around? I don't believe it's specific to my OS. It must be somewhere in the high-level UI code. I'm seeing the same on Windows 10 and MacOS 10.15 (it's currently downloading an update to 11.2) I've made an effort to try and repro it for you. Please try opening in Chrome or Safari: deniskak.github.io/crux_hostingIf you don't see the issue immediately, try zooming around so that Unity resolution is changed, then click "add" a few times.
|
|
|
Post by echo17 on Feb 22, 2021 13:43:34 GMT
Thanks for the extra information. I was able to reproduce by changing the resolution mid-session. It seems this has something to do with the ScrollRect's Movemet Type setting in the inspector. If you change it from Elastic to Clamped it works fine. My guess is that when the resolution is changed and a new record is added, the size change of the ScrollRect causes it to do a giant leap, calculated by the elastic equation. It appears to be jumping way off screen and then settling back to the proper size.
Fortunately, there is an easy solution to this. In Demo #8, change the Controller.cs AddNewRow method to this:
/// <summary> /// This function adds a new record, resizing the scroller and calculating the sizes of all cells /// </summary> public void AddNewRow() { scroller.ScrollRect.movementType = UnityEngine.UI.ScrollRect.MovementType.Clamped;
// first, clear out the cells in the scroller so the new text transforms will be reset scroller.ClearAll();
// reset the scroller's position so that it is not outside of the new bounds scroller.ScrollPosition = 0;
// second, reset the data's cell view sizes foreach (var item in _data) { item.cellSize = 0; }
// now we can add the data row _data.Add(new Data() { cellSize = 0, someText = _data.Count.ToString() + " New Row Added!" });
ResizeScroller();
// optional: jump to the end of the scroller to see the new content scroller.JumpToDataIndex(_data.Count - 1, 1f, 1f);
scroller.ScrollRect.movementType = UnityEngine.UI.ScrollRect.MovementType.Elastic; }
Note that I added lines at the beginning and end of the method to change the movement type so that this jump is not calculated by Unity's ScrollRect.
Alternatively, if you don't need Elastic movement, you can just set your ScrollRect's movement type to Clamped and leave it there.
|
|
dpy
New Member
Posts: 7
|
Post by dpy on Feb 27, 2021 20:31:01 GMT
Thanks for the extra information. I was able to reproduce by changing the resolution mid-session. It seems this has something to Note that I added lines at the beginning and end of the method to change the movement type so that this jump is not calculated by Unity's ScrollRect. ... Alternatively, if you don't need Elastic movement, you can just set your ScrollRect's movement type to Clamped and leave it there. Thanks. Unfortunately, this code didn't make any difference. Note that I mentioned regarding changing the size at run-time as it's easier to repro but I get exactly the same issue if I don't change the size in run-time rather select one of the resolutions in the editor before I enter play mode. I need the elastic behaviour and smooth scrolling. I've done some debugging wondering where the crazy scrollPosition values were coming from and I believe it's due to rectTransform.sizeDelta = new Vector2(size.x, float.MaxValue); in Controll.cs within ResizeScroller. I saw that Unity was taking a reference to the scrollPosition passing it to LayoutRebuilder that would be then adjusting this value from max float value to the target value over multiple frames necessary for elastic behaviour. I think it may be harder for your to repro as this may depend on framerates. Anyway, I've changed the resize code to rectTransform.sizeDelta = new Vector2(size.x, 0.0f); and not seeing the issue anymore. The size of the cells is still correctly calculated. I've got another question but will raise a separate topic.
|
|