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
0
Question by josueyeo · Jun 05, 2013 at 04:08 PM · mousekeyboardscrollbar

how to assign a key to the scrollbar

Can someone tell me if it is possible to assign a keyboard key to use on the scrollbar to scroll up or down instead of using my mouse scroll wheel?

Comment
Add comment · Show 2
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 Veehmot · Jun 05, 2013 at 04:25 PM 0
Share

Are you referring to the scrollbars of the GUI, like GUI.VerticalScrollbar?

avatar image josueyeo · Jun 06, 2013 at 07:49 PM 0
Share

yes Veehmot That is what i´m talking about,it is possible?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Veehmot · Jun 06, 2013 at 09:16 PM

You should change the value of the Scrollbar using an input function. For example, to change the scrollbar via Input in the example of GUI.VerticalScrollbar, you should add this to the Update function.

 void Update() {
     if (Input.GetKeyDown(KeyCode.DownArrow)) {
         vSbarValue += 1f;
     } else if (Input.GetKeyDown(KeyCode.UpArrow)) {
         vSbarValue -= 1f;
     }
 }

Or with GUI.BeginScrollView as in your example:

 void Update() {
     if (Input.GetKeyDown(KeyCode.DownArrow)) {
         scrollPosition.y += 1f;
     } else if (Input.GetKeyDown(KeyCode.UpArrow)) {
         scrollPosition.y -= 1f;
     }
 }


Comment
Add comment · Show 4 · 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 josueyeo · Jun 06, 2013 at 10:04 PM 0
Share

and what about GUI.BeginScrollView ?

avatar image josueyeo · Jun 06, 2013 at 10:11 PM 0
Share

for example if I got this script

using UnityEngine; using System.Collections;

public class SkinTest : $$anonymous$$onoBehaviour

{

 public GUISkin thisAmigaGUISkin;
 
   
  public Vector2 scrollPosition = Vector2.zero;
 void OnGUI() {
     scrollPosition = GUI.BeginScrollView(new Rect(10, 10, 240, 300), scrollPosition, new Rect(0, 0, 220, 500));
     GUI.Button(new Rect(0, 0, 100, 20), "Top-left");
     GUI.Button(new Rect(120, 0, 100, 20), "Top-right");
     GUI.Button(new Rect(0, 180, 100, 20), "Bottom-left");
     GUI.Button(new Rect(120, 180, 100, 20), "Bottom-right");
     GUI.EndScrollView();
 }

}

avatar image Veehmot · Jun 07, 2013 at 02:25 AM 0
Share

I have updated the answer to include your example as well.

avatar image josueyeo · Jun 07, 2013 at 04:20 AM 0
Share

hey Veehmot i have one more question, guess what i make it work as you told me, but in my project i got more than 5 GUI.BeginScrollViews, and i did apply what you just told me to each of them, but when i scroll one, all of them scrolls together, is there a way to use the same keys but make it move separately?

avatar image
0

Answer by josueyeo · Jun 07, 2013 at 02:50 AM

thank you Veehmot, God bless you, Thank you very much

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

15 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

Related Questions

How do i change controller from keyboard to mouse?? 1 Answer

Unity UI Mouse + Keyboard navigate, Un-Highlight button choice on mouse over 0 Answers

Unity 4.6.3f1 bug or normal behaviour? MouseButtonDown cancelled/ ignored by key press 0 Answers

How to scrolling scrolling panel using Script or Keyboard 1 Answer

Best Practice Multiple Control Methods 1 Answer


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