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 David_29 · Jul 22, 2014 at 04:14 AM · guibugscrollviewgui.label

GUI Label/Text Area Doesn't Show Up Inside Scrollview

After I read some documents on how to make a simple scrollview and added some contents inside scrollview is quite straightforward and it worked. Now, I decided to add some GUI text or label to add this onto the scrollview. When I run it, it appears blank. Here's the code.

 void OnGUI() {
         scrollPosition = GUI.BeginScrollView(new Rect(0, (Adjust.getButtonSquare(false, true, 16)/2) - (Adjust.getButtonSquare(false, true, 14)/2), Adjust.getButtonSquare(true, false, 10), Adjust.getButtonSquare(false, true, 14)), scrollPosition, new Rect(0, Adjust.getButtonSquare(true, false, 10), 220, 1200));
         GUI.DrawTexture (new Rect(0, 0, 9999, 9999), guiTexture.texture);
         string text = GUI.TextArea(new Rect(10, 10, 209, 209),
             "Top-left \n" +
             "Top-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left " +
             "\nTop-left \n");
 //        text [0].transform.position = new Vector3 (0, 0, 0);
 //        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();
     }


UPDATE: By the way, if you're wondering where did I get this such code/method under Rect parameters and those are static return variables from Adjust.cs code. Here's the preview so you can understand its reference.

 using UnityEngine;
 using System.Collections;
 
 /**
  * 
  * Script behavior for GUI position and size.
  * 
  */
 
 public class Adjust : MonoBehaviour {
 
     public bool setToLandscape = false;
 
     public static bool setToLandscapeStatic; // --> To be used for sharing reference.
     
     
     
     
 
     void Start() {
         setToLandscape = setToLandscapeStatic;
     }
     
     
     
     
 
     public static float GetButtonWidth() {
         if(setToLandscapeStatic) {
             return (Screen.width/16) * 7;
         } else {
             return (Screen.width/10) * 6;
         }
     }
     
     
     
     
 
     public static float GetButtonHeight() {
         if(setToLandscapeStatic) {
             return (Screen.height/10) * 0.25f;
         } else {
             return (Screen.height/16) * 1.25f;
         }
     }
     
     
     
     
 
     public static float GetLocationX(float x) {
         if(setToLandscapeStatic) {
             return (Screen.width/16) * x;
         } else {
             return (Screen.width/10) * x;
         }
     }
     
     
     
     
 
     public static float GetLocationY(float y) {
         if(setToLandscapeStatic) {
             return (Screen.height/10) * y;
         } else {
             return (Screen.height/16) * y;
         }
     }
     
     
     
     
 
     public static float getButtonSquare(bool width, bool height, float value) {
         if(height) {
             return GUI.skin.button.fixedHeight = (Screen.height/16) * value;
         } else if(width) {
             return GUI.skin.button.fixedWidth = (Screen.width/10) * value;
         } else {
             return (Screen.height/16) * value;
         }
     }
     
     
     
     
 
     public static float getButtonSquare() {
         return (Screen.height/16) * 2;
     }
 
 }
 


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
0
Best Answer

Answer by David_29 · Jul 22, 2014 at 06:34 AM

I found the error and something had to fix on the third parameter of GUI.BeginScrollView. I have to set the TOP position of the 'Rect' to 0.

BEFORE

 scrollPosition = GUI.BeginScrollView(new Rect(0, (Adjust.getButtonSquare(false, true, 16)/2) - (Adjust.getButtonSquare(false, true, 14)/2), Adjust.getButtonSquare(true, false, 10), Adjust.getButtonSquare(false, true, 14)), scrollPosition, new Rect(0, Adjust.getButtonSquare(true, false, 10), 220, 1200));

AFTER

 scrollPosition = GUI.BeginScrollView(new Rect(0, (Adjust.getButtonSquare(false, true, 16)/2) - (Adjust.getButtonSquare(false, true, 14)/2), Adjust.getButtonSquare(true, false, 10), Adjust.getButtonSquare(false, true, 14)), scrollPosition, new Rect(0, 0, 220, 1200));
     
         







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

2 People are following this question.

avatar image avatar image

Related Questions

GUI.TextField - Android: Unfocusing with click instead of Ok-button causes critical error 0 Answers

4.6 GUI Button inside a scrolling Text Box 0 Answers

Why is my scrollview jittering? 1 Answer

GUI Windows not being removed properly in a network 1 Answer

How can I combine a Mask with a Scroll Rect to limit the visible content? 2 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