Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 TheNoobieWaffle · Sep 28, 2018 at 05:38 AM · guiguilayoutgroup

GUI.BeginGroup for GUILayout elements

Hey guys. I'm trying to use GUI.BeginGroup() and GUI.EndGroup() to create 'nodes' for a tree editor. Im testing creating these individual areas to use the GUILayout elements at, but I seem to have the wrong idea about GUI.BeginGroup(). Can anyone set me straight? As this code suggests, the lower box is rendered first, then the upper box. But it seems that the first line in the top box is skipped, and I believe it has to do with the fact that a first line was written to in the lower box. Not sure why this is. Not sure how to fix it.

         for (int index = 0; index < 2; index++) {
             GUI.Box(new Rect(0, 50 + (index * -50), 50, 50), "_");
             GUI.BeginGroup(new Rect(0, 50 + (index * -50), 50, 50));
             GUILayout.Label(index.ToString());
             GUI.EndGroup();
         }

alt text

screenshot-5.png (5.2 kB)
Comment
Add comment · Show 1
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 NoDumbQuestion · Sep 28, 2018 at 10:19 AM 0
Share
          for (int index = 0; index < 2; index++) {
              GUI.BeginGroup(new Rect(0, 50 + (index * -50), 50, 50));
              GUI.Box(new Rect(0, 50 + (index * -50), 50, 50), "_");            
              GUILayout.Label(index.ToString());
              GUI.EndGroup();
          }

See what happen

1 Reply

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

Answer by Bunny83 · Sep 28, 2018 at 12:15 PM

The layout system works somewhat indepentently from the normal GUI system, Mixing isn't really recommended. However if you need a layout area inside "normal" GUI code you have to use GUILayout.BeginArea / EndArea.


Note that there is no reason to use GUI.Box explicitly. Layout groups as well as the BeginArea accepts a custom style. So you can just do

          GUILayout.BeginArea(new Rect(0, 50 + (index * -50), 50, 50), "box");
          GUILayout.Label(index.ToString());
          GUILayout.EndArea();

Though if you have overlapping nodes you may want to actually use a GUILayout.Window instead. Though it's up to you how you implement your nodes.

Comment
Add comment · Show 2 · 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 Bunny83 · Sep 28, 2018 at 12:18 PM 0
Share

You might want to have a look at my I$$anonymous$$GUI crash course. The original post is here but since UnityAnswers has messed up it's mark down rendering i've copied it into a github repository as it actually renders mark down properly ^^.

avatar image TheNoobieWaffle Bunny83 · Sep 28, 2018 at 09:13 PM 0
Share

Thank you very much!

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

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

Related Questions

Additional parameters for GUILayout.Label 1 Answer

Non rectangular GUI Mask / Matte? 2 Answers

How to disable horizontal scrollbar in GUILayout scroll view? 3 Answers

how to find out the absolute coordinate? 0 Answers

button with content in multiple colors 3 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