• 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
Question by Cyber-X-Zone · Oct 18, 2012 at 06:22 PM · guibuttonnot workingskin

GUI Button not working...but the the script is correct...

I have created the main menu but then a GUI Button problem came up...No errors showing, Button is being displayed...But the button does not work even after many times I have clicked it...Here's the script:

 if(isArcadeLambo == true){
 
  GUI.Label(Rect(800, 300, 0, 70), "Speed = 200km/hr", "description");
 
  if(GUI.Button(Rect((Screen.width/2)+560, 470, 0, 70), "Buy for Rs.95,000/-","costButton"))
  {
 
   isPlay = true;
 
   levelScript.cash -= 95000;
  }
 }

All is correct...but it doesn't work..(I have added a new GUI skin for this script, so if its the problem of GUI skin..it's not as I have already checked it...)

If anybody have the solution to this gigantic problem, plz help me... Thanx in advance....

Comment

People who like this

0 Show 13
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 whydoidoit · Oct 18, 2012 at 06:23 PM 1
Share

And that script is in an OnGUI call? You've put a Debug.Log just above isPlay = true and it isn't appearing?

avatar image phodges · Oct 18, 2012 at 07:20 PM 0
Share

In order to trace your problem, have you considered adding a GUI.Label that displays the value of levelScript.cash? It might be helpful to confirm that the button really is doing nothing. You might find that the problem lies elsewhere.

avatar image Cyber-X-Zone · Oct 19, 2012 at 10:13 AM 0
Share

No,the problem doesn't lies elsewhere... I have created a GUI label and it works fine..Only the Button is not acting properly even if it is in On GUI() function and I have added all the textures necessary for a GUI skin...

avatar image whydoidoit · Oct 19, 2012 at 10:14 AM 0
Share

Can you:

  • See the button

  • See a Debug.Log per my suggestion above

avatar image Cyber-X-Zone · Oct 19, 2012 at 10:18 AM 0
Share

I can see the button..But the problem is that it's hover and Active function is not working...So how will Debug.Log work if button can't be clicked...

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by V4siliy · Oct 19, 2012 at 12:15 PM

Rect parametrs are: float left, float top, float width, float height.

Your button's width == 0, and maybe problem is in it.

Comment

People who like this

0 Show 0 · 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

Answer by phodges · Oct 19, 2012 at 12:16 PM

This problem was resolved in the comments: a small error in specifying the control rectangle.

Comment

People who like this

0 Show 0 · 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

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Embed GUI Skin in GUI Button 2 Answers

(4.6 UI) How to set up a window with x buttons, with a scroll bar? 1 Answer

Button Turns Off and On Object 1 Answer

Null reference exception[SOLVED] 1 Answer

Resolutions 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