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
1
Question by frankyboy450 · Oct 09, 2013 at 07:21 AM · buttonsscrollviewguilayout

buttons to control ScrollView

Hi. Is it possible to add some buttons to the left and right side of a GUILayout.ScrollView that can beused for scrolling instead of using the slider?

so that it looks like this

left button| Scroll View| right button

<--|scroll view here|-->

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

1 Reply

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

Answer by sed · Oct 09, 2013 at 09:44 AM

If your ScrollView looks like this:

 scrollPosition = GUILayout.BeginScrollView(scrollPosition, 
                  GUILayout.Width(150), GUILayout.Height(150));

You can use:

 if(GUILayout.Button(...))
 {
     scrollPosition.x = scrollPosition.x + 10; // vertical
     scrollPosition.y = scrollPosition.y + 10; // horizontal
 }

To scroll by pressing a button. To scroll the other way just swap + for -.

Comment
Add comment · Show 3 · 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 frankyboy450 · Oct 09, 2013 at 03:40 PM 0
Share

Won't work.

Assets/Scroll View/ScrollWindow.cs(22,25): error CS0019: Operator +=' cannot be applied to operands of type UnityEngine.Vector2' and `int'

avatar image sed · Oct 09, 2013 at 05:14 PM 0
Share

It's because scrollPosition is Vector2. Just fiddle with that and you will have your solution working. I have updated the answer to reflect that.

On a side note - you have to explore more on your own if you want to be a proficient programmer :)

avatar image frankyboy450 · Oct 09, 2013 at 08:14 PM 0
Share

Yeah. forgot to remove that comment. After a while I figured out how to fix it ;) Now there's only some problems with placing the buttons the right place, but that won't be too hard. Thanks for the help :)

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

16 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

Related Questions

NGUI Buttons in ScrollView. 0 Answers

Scrollbar is not appearing in my list, I am using Unity 4.6 1 Answer

ScrollView - How to stop infinite scrolling? 1 Answer

4.6 Beta uGUI: Putting UI elements in a ScrollRect via code 1 Answer

How to dynamically set the no of buttons in a grid layout? 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