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 clarioncat · Nov 22, 2013 at 01:36 PM · guilabelbox

OnGUI Labels affect different boxes?

alt text

Hi guys. I am currently working an a dialogue system. What I want to right now is having two different speech bubbles (one for each speaker) pop up. My approach is having two different boxes withing two different areas in two OnGUI functions. Then filling them with different text an options via labels and buttons.

All of this is KIND of working, but here is my problem: When one of the box has a label in it, the OTHER box (not containing a label) with two button options kind of pretends that the same label was there, too – and shows the buttons at that exact position where the label in the other box ends. The picture attached shows this problem.

Okay, so I understand that the label obviously affects both boxes, but I don't understand why – from my code it should be two different functions and areas and therefore different boxes?

I would be very happy for any ideas and solutions to my problem. I just want to be able to display different text and buttons independently in each boxes.

Thanks in advance!!

Here is the code:

     void OnGUI(){
         
         GUI.skin = dialogueGUI;
 
 
 
         if (showDialogue&&dan01)
         {
 
 
             GameObject Dusty = GameObject.Find("Dusty");
             PlayerControl playerControl = Dusty.GetComponent<PlayerControl>();
             playerControl.canMove = false;
 
             GameObject Dan = GameObject.Find("Dan");
 
             GUI.BeginGroup (new Rect (700, 100, 500, 200));
 
             GUI.Box (new Rect (0, 0, 0, 0), "");
             
             if (dialogue1_1)
             {
             
                 GUILayout.Label("Stop running around, will you? I am nervous enough already. This place gives me the creeps. I really wish this was over and done with. Like, yesterday.");
 
             }
             
             if (dialogue1_2a)
             {    
                     
                 GUILayout.Label("Phew! Thought I was the only one.");
                 
                     
             }
             
             if (dialogue1_2b)
             {    
                     
                 GUILayout.Label("Well, I'm glad at least one of us is enjoying herself.");
                 
 
             }
             
             
             GUI.EndGroup ();
         
 
             if (showDialogue&&dan01)
             {
 
             
                 StartCoroutine(Wait());
 
                 
 
 
                 GUI.BeginGroup (new Rect (220, 270, 500, 200));
                 
                 GUI.Box (new Rect (0, 0, 0, 0), "");
                 
                 if (dialogue1_1)
                 {
 
                     if (GUILayout.Button("Yeah, me too."))
                     {
                         dialogue1_1 = false;
                         dialogue1_2a = true;
                     }
                     
                     if (GUILayout.Button("Really? I'm rather excited!"))
                     {
                         dialogue1_1 = false;
                         dialogue1_2b = true;
                     }
 
                 }
 
                 if (dialogue1_2a)
                 {    
                     
                     if (GUILayout.Button("Don't be too hard on yourself."))
                     {
                         dialogue1_2a = false;
                         dan01 = false;
                         dan01b = true;
                         showDialogue = false;
                         playerControl.canMove = true;
                         
                     }    
                 }
                 
                 if (dialogue1_2b)
                 {    
                     
                     if (GUILayout.Button("You could really ease up a bit."))
                     {
                         dialogue1_2b = false;
                         dan01 = false;
                         dan01b = true;
                         showDialogue = false;
                         playerControl.canMove = true;
                     }    
                 }
             }
 
             GUI.EndGroup ();
 
 
             
 
 
         }
         
         if (showDialogue&&dan01b){
             
 
             GUI.BeginGroup (new Rect (Screen.width / 2 - 350, Screen.height / 2 + 150, 700, 140));
             GUI.Box (new Rect (0,0,600,200), "");
         
                 GUILayout.Label("It's good to see you showing some compassion.");
 
             GUI.EndGroup ();
         
             }
         }
         
 
bildschirmfoto 2013-11-22 um 14.15.11.png (226.0 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

1 Reply

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

Answer by Landern · Nov 22, 2013 at 03:13 PM

It appears you are mixing Layout Modes. For a break down click/follow this link(Unity - Layout Modes).

When i replaced some of your code using the Automatic layout(GUILayout) instead of fixed, replacing things like GUI.BeginGroup with GUILayout.BeginArea, etc. Your described problems went bye-bye. Give the documentation that i linked above a quick read and i think you will begin to understand what happened here.

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 clarioncat · Nov 23, 2013 at 03:03 PM 0
Share

Thank you so much; I really wasn't aware of me mixing up fixed and automatic layout. Great 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

17 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

Related Questions

Why GUI Doesn't appears? 1 Answer

Trouble Positioning a GUILayout.Label, or as a button? 0 Answers

Making a text box appear after a certain gameObject is destroyed 0 Answers

Relate font size to screen size in GUISkin 2 Answers

How to find all GameObjects within a specific field of view/box 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