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 Ochreous · Sep 20, 2012 at 12:11 AM · c#gui

HorizontalScrollbar not appearing in GUILayout.BeginScrollview C#

Hi everyone, I have been trying to get the Horizontal Scrollbar to appear in GUILayout.BeginScrollview.But for some reason I just can't get it to appear. Do I need to setup different parameters to get it to appear?

     public Vector2 scrollPosition;
    
     void OnGUI() {
         scrollPosition = GUILayout.BeginScrollView(scrollPosition,
         GUILayout.Width(100), GUILayout.Height(100));
 
      
         
         GUILayout.EndScrollView();
         
         
     }
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

3 Replies

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

Answer by Ochreous · Sep 20, 2012 at 05:14 AM

I figured out how to make the horizontal scrollbar show up. You have to put in two booleans in the beginscrollview. One bool is for the horizontal scrollbar and the other is for the vertical scrollbar.

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
avatar image
0

Answer by kmeboe · Sep 20, 2012 at 12:48 AM

I believe you have to add enough content to the view before the bar will show up. If the content can fit inside the width/height you've defined, the scroll bars won't show up.

Follow the example on this page, and see if it works: http://docs.unity3d.com/Documentation/ScriptReference/GUILayout.BeginScrollView.html

Comment
Add comment · Show 1 · 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 Ochreous · Sep 20, 2012 at 01:09 AM 0
Share

I did everything in the tutorial but the Horizontal Scrollbar still didn't show up.

avatar image
0

Answer by kmeboe · Sep 20, 2012 at 03:56 AM

Try the following steps:

  1. Create a new project

  2. Create a new C# script called "test".

  3. Paste the following code into test:

    using UnityEngine; using System.Collections;

    public class test : MonoBehaviour { public Vector2 scrollPosition; public string longString = "This is a long-ish string"; public string longerString = "This is an even longer string. It is very long. I'm still talking about the string.";

      void OnGUI() {
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(100), GUILayout.Height(100));
             GUILayout.Label(longString);
             GUILayout.Label(longerString);
             if (GUILayout.Button("Clear"))
                 longString = "";
             
             GUILayout.EndScrollView();
             if (GUILayout.Button("Add More Text"))
                 longString += "\nHere is another line";
             
         }
     }
    
    
  4. Attach the test script to the main camera.

Give this a shot, and let me know if the scroll bar shows up.

Comment
Add comment · Show 1 · 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 kmeboe · Sep 20, 2012 at 03:58 AM 0
Share

Not sure why the formatting is messed up. $$anonymous$$ake sure you grab everything, starting at "using UnityEngine", and ending at the last bracket, which is outside the code block;. Some of the newlines will be missing, but they're not needed.

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

10 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

Related Questions

C# How to Drag and Scale with Mouse Window 0 Answers

Changing GUI.Box opacity 3 Answers

A node in a childnode? 1 Answer

C# how to create a Descending GUI List 1 Answer

Make a custom score counter in unity with c# 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