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 StudentGameDev · Sep 04, 2013 at 05:09 PM · guiguilayout

Correct usage of GUILayout.BeginVertical

So I''m having a problem setting up GUI interface, placing elements where I want them..

I get nothing on-screen when the button Show Server Logs is pressed, I read up about the GUILayour tutorial but still can't wrap my head around it..

Is there something I am doing wrong? Should I place the GUILayout.BeginVertical somewhere else in the OnGUI()?

     void OnGUI()
     {
         GUILayout.BeginArea(new Rect(10, 10, Screen.width, Screen.height));
 
         if (Network.peerType == NetworkPeerType.Disconnected)
         {
             if (GUILayout.Button("Start Server", GUILayout.Width(120), GUILayout.Height(25)))
             {
                 Network.InitializeSecurity();
                 Network.InitializeServer(_maxConnections, _serverPort, true);
 
                 Debug.Log("Server is starting up..");
             }
         }
         else
         {
             if (GUILayout.Button("Show Server Logs", GUILayout.Width(120), GUILayout.Height(25)))
             {
                 Debug.Log("Showing server logs.");
                 GUILayout.BeginVertical();
                 GUILayout.Box("Server Console" + _serverMessages, GUILayout.Width(Screen.width), GUILayout.Height(200));
                 GUILayout.EndVertical();
             }
 
             if (GUILayout.Button("Shutdown Server", GUILayout.Width(120), GUILayout.Height(25)))
             {
                 Network.Disconnect(500);
 
                 Debug.Log("Server is shutting down..");
             }
         }
         GUILayout.EndArea();
     }
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

Answer by perchik · Sep 04, 2013 at 05:22 PM

Well in this case, you're not actually doing anything with BeginVertical(), which is used to automatically lay out a bunch of items in a vertical column (one under each other), but since you only have one item in the vertical layout section, it's not going to do anything at all.

I'd try getting rid of the GUILayout.Width() and GUILayout.height() calls and see if it works (but with the wrong sizes). If it does, I'd wager that your sizes are causing it to fall off the screen or something.

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 StudentGameDev · Sep 04, 2013 at 05:31 PM 0
Share

Hi Perchik, thanks for the reply.

I have tried it several times without the GUILayout.width and GUILayout.height calls. But I think I got some confusion as to how it's all working together, since the GUILayout tutorial page, shows all three in use. BeginArea() to wrap an entire GUI area, inside first being called Horizontal, then a button then the Vertical, then both groups are closed and so is the area. What I don't understand is why the box doesn't show up at all, even tried it with and without GUILayout.width/height.

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

GUI Error: You are pushing more GUIClips than you are popping? 0 Answers

TextField does not show up 2 Answers

GUILayout Textfield not editable just static 1 Answer

Using treeview OnGUI with GUIlayout 0 Answers

How to change thickness of ScrollBar of GUILayout ScrollView? 0 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