Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
6
Question by Mmmpies · Dec 17, 2014 at 09:36 PM · uivalue4.6openscrollbar

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: WorkingFirstTimeMenuIsOpened

Then Fails When Menu Closed And Re-Opened NotWorkingWhenICloseTheMenuAndOpenItAgain

scrollbarvalueworking.png (68.8 kB)
scrollbarvaluenotworking.png (65.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
29
Best Answer

Answer by d_kieffer · Dec 30, 2014 at 08:00 PM

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.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mmmpies · Jan 10, 2015 at 02:28 PM 0
Share

Thanks @d_kieffer and sorry for the slow response.

Yep I worked this out as well but stupidly failed to update this post so accepting your answer as absolutely the correct way to handle this.

Pivot's, it turns out, are really important when creating instantiated menu items with the new UI.

avatar image T_Lavell · Feb 21, 2015 at 02:03 AM 1
Share

Same exact issue, changing the pivot worked for me too. Thanks d_kieffer!

avatar image Jure-Veler · Apr 12, 2015 at 11:47 AM 1
Share

I had the exact same issue, was trying to solve it for a while now. Thanks D_kieffer !

avatar image Mikenekro · Jun 25, 2015 at 01:09 AM 1
Share

Thanks for the answer. Simple and effective.

avatar image Xanatos_88 · Apr 12, 2018 at 09:08 PM 1
Share

For newcomers to this thread, I can confirm that this solution does work in every version of the engine. I'm currently using 2017.3.1f1

Show more comments
avatar image
0

Answer by Mmmpies · Dec 18, 2014 at 08:53 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

4.6 UI - how to make a dynamic scrollbar? 2 Answers

TextMeshPro dropdown default value change 0 Answers

Move gameobject to button in new 4.6? 0 Answers

Unity 4.6 Beta Controller Menu Button Movement 0 Answers

Unity 4.6 - Rotating with Mouse Issue 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges