UI 4.6 Scrollbar.value sets to 1 first time but not when opened again

Creating a menu from prefabs using a scrollrect and scrollbar as shown in Stuart Spences YouTube Example.

The menu works fine an I worked out that setting the Scrollbar.value = 1 means it always starts at the top of the menu.

So I reference the scrollbar and set it’s value. It works perfectly when the Menu opens first time but not when I close the menu and open it again.

Debug.Log shows it is setting the value to one but it must then set it to .5

No idea why, anyone seen that or know a way to force it to stay at 1 when the menu opens?

allScrollbar = GameObject.FindGameObjectWithTag("allScrollBar");
		allScrollbar.GetComponent<Scrollbar>().value = 1;
		Debug.Log ("Setting the scrollbar to 1 at " + Time.time + " vlaue = " + allScrollbar.GetComponent<Scrollbar>().value);

Works First Time:

Then Fails When Menu Closed And Re-Opened

I had a similar problem that seemed to stem from using the Content Size Fitter component on the content that I wanted to scroll. I could set the Scroll Bar’s Value to 1 but it would always reset itself to 0.5.

THE FIX: In the Rect Transform component of your scrollable content the Pivot Y value is probably set to 0.5. Change this Pivot Y value to 1. That should force your scrollable content to always start from the top.

OK I set a check to record the menuOpenTime then in Update checked Time.time to see if it was > menuOpenTime + 0.1f.

Still failed so set that to 0.2f and it fixed it.

No idea why it always works first time then menu opens but on subsequent times it fails unless I check it. The menu is doing exactly the same thing each time I open it but 100% of the time it works when the menu first opens but fails on all occasions I open it after that.

This is just a test scene but in reality I’d want to stop time when in menus so I suppose I’d need to count passed time with fixedDeltaTime.

Maybe something that needs fixing in the UI but then it’s still early days for the new UI.