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 21, 2012 at 03:04 AM · c#guiguilayout

Using GUI and GUILayout at the same time

Hi everyone, I've heard that if you use both GUI and GUILayout at the same time you get lots of errors, is that true? I've created a script that uses both GUI and GUILayout and I've not recieved any console errors

     Void OnGUI(){
             GUI.Box(new Rect(Screen.width/3.5f, Screen.height/4,Screen.width/2-50, Screen.height/2+50),"");
             GUILayout.BeginArea( new Rect(Screen.width/3.5f, Screen.height/4, Screen.width, Screen.height));
           scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (100), GUILayout.Height (100));
     }
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 Bunny83 · Sep 21, 2012 at 03:18 AM

No, in general they can be used at the same time. Most GUILayout functions call internally the GUI functions. They just wrap the layouting around them. The GUILayout functions process the layout event, create layout groups and store them for the repaint event. At Repaint they just call the GUI function with the Rect they got from the layout groups. What might get you in trouble is GUI.Window and GUILayout.Window because of the special event handling.

Mixing single / seperate elements is no problem, but there are some things that aren't compatible. GUI.BeginGroup and layout elements won't work as well as GUILayout.BeginScrollView with GUI elements in it.

Is this your whole script? You're not closing the layout group for the LayoutArea(EndArea) and the ScrollView(EndScrollView). Also your scrollview is empty, so there's actually nothing to display.

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 21, 2012 at 03:39 AM 0
Share

Nope, that's just a chunk of it. Thanks for the clarification.

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

11 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

Related Questions

Using treeview OnGUI with GUIlayout 0 Answers

C# Putting a Series of Labels in Between a Series of Buttons 1 Answer

How do you CORRECTLY call methods from another C# file 1 Answer

Using an On-Screen GUI Button to show a GUI? 1 Answer

Method is called, but GUI doesn't show up 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