• 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 Kristoff · Apr 01, 2013 at 01:03 PM · guitextguilayer

GUI is not showing up, but script seems to be fine

Hi!

I made this simple GUI script based on some tutorials, and after applying it to empty game object and pushing play, GUI won't show up. Any ideas?

private var buttonWidth:int = 200; private var buttonHeight:int = 50; var spacing:int = 25;

 function OnGUI() 
 {
     GUILayout.BeginArea(Rect(Screen.width/2 - buttonWidth/2, Screen.height/2 - 200, buttonWidth, - 400));
         if(GUILayout.Button("New Game", GUILayout.Height(buttonHeight)))
         {
             Application.LoadLevel("Game");
         }
         GUILayout.Space(spacing);
         if(GUILayout.Button("Continue", GUILayout.Height(buttonHeight)))
         {
             Application.LoadLevel("testcontinue");
         }
         GUILayout.Space(spacing);
         if(GUILayout.Button("Exit", GUILayout.Height(buttonHeight)))
         {
             Application.Quit();
         }
     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
0
Best Answer

Answer by robertbu · Apr 01, 2013 at 01:31 PM

For the last parameter in your GUILayout.BeginArea() you are specifying a negative value (-400). Change it to 400.

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 Kristoff · Apr 01, 2013 at 04:31 PM 0
Share

Thanks! $$anonymous$$oderator, please close the question.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 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

Related Questions

Multiple Cars not working 1 Answer

How To Make GUI Buttons Load/Quit 1 Answer

GuiTexture Width Change 1 Answer

How to save and load text in a GUI TextArea 1 Answer

Help Changing GUI Text size 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges