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 /
This question was closed Sep 05, 2015 at 12:52 AM by Chadley for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Chadley · Jul 31, 2014 at 08:55 PM · 2dbuttons

Why doesn`t my GUI Button show up?

I have a C# Script (for a 2D platformer) which for the most part works but the only thing that doesn`t work on it is the GUI button and I don`t know why(it is the on with the if before it). All of the other Labels work other than the Retry Button.

Here is the Script:

 using UnityEngine;
 using System.Collections;
 
 public class GameOverScript : MonoBehaviour {
 
     int score = 0;
 
     void Start () {
         score = PlayerPrefs.GetInt ("Score");
     }
 
     void OnGUI()
     { 
         GUI.Label(new Rect(Screen.width / 2 - 40, 50, 80, 30), "GAME OVER");
 
         GUI.Label (new Rect(Screen.width / 2 - 40, 300, 80, 30), "Score: " + score); 
         if(GUI.Button(new Rect(Screen.width / 2 - 30, 350, 60, 30), "Retry?")) 
             {
                 Application.LoadLevel(0);
             }
     }
 }

Comment
Add comment · Show 5
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 robertbu · Jul 31, 2014 at 10:29 PM 0
Share

Not sure if this is your problem, but your last label appears to partly overlap the rectangle you use for your Button. You should be seeing a piece of the button though.

avatar image NoName115 · Jul 31, 2014 at 11:34 PM 0
Share

I dont really know, where is your problem but the statement if (GUI.Button....) mean that if you click on that button, that something will happend.

avatar image Kiwasi · Jul 31, 2014 at 11:42 PM 0
Share

Can you be a little more specific, does your button not appear, or does clicking on it do nothing?

avatar image Chadley · Aug 01, 2014 at 01:22 PM 0
Share

No, the button and the "Retry?" text doesn`t appear at all. The players score and the "GA$$anonymous$$E OVER" text appears, its just that the button and its text "Retry?" is not showing at all.

What I have done is created a new scene with this script and attached it to a camera. I then added this scene in build so that it has a 1 next to it. When I lose in the game, Scene one should appear with the texts and button, but the button (along with the Retry text) is not visible anywhere.

avatar image VIPINSIRWANI · Aug 01, 2014 at 01:31 PM 0
Share

Check your Y-Value (its to high put logic for that) may be you will get what you are looking

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Chadley · Aug 01, 2014 at 02:19 PM

"Check your Y-Value (its to high put logic for that) may be you will get what you are looking" - VIPINSIRWANI

Thank you so much VIPINSIRWANI. I lowered my Y-Value down to 200 and now the button appears , thank you.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with Force on rigidbody, not always the same force 0 Answers

buttons not working in android. 1 Answer

2D Buttons 1 Answer

Mouse Click to keyCode 1 Answer

Getting a custom class to contain a certain script. 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