• 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
-1
Question by logang · Mar 19, 2013 at 06:29 PM · guiprojectjavavarlost

Java code not working. LOST PROJECT

Okay so I was just making a game i spent alot of time on it and saddy i deleted it on accident so I was trying to type my long script over again and it is not working. here is the code:

 var Glock17   : GameObject;
 
 var Glock17Aim    : GameObject;
 
 private var ShowMenu = false;
 
 private var Rank = 0;
 private var Kills = 0;
 private var EXP = 0;
 private var Wave = 0;
 
 function Start () {
     Glock17.SetActive(true);
     Glock17Aim.SetActive(false);
 }
 
 function Update () {
 
      if(Input.GetMouseButtonDown(1)) {
     Glock17.SetActive(false);
     Glock17Aim.SetActive(true);
     }
     if(Input.GetMouseButtonUp(1)) {
     Glock17.SetActive(true);
     Glock17Aim.SetActive(false);
     }
     
     ShowMenu = true;
     if(ShowMenu == false) {
     if(Input.GetKeyDown ("space")) {
         ShowMenu = true;
     }
     }
     if(ShowMenu == true) {
     if(Input.GetKeyUp ("space")) {
         ShowMenu = false;
     }
     }
 }
 function OnGUI() {
     
     if(ShowMenu == true) {
         GUI.Box (Rect(0, 0, 640, 480), "Pop Up" );
         GUI.Box (Rect(0, 0, 640, 480), "Pop Up" );
 
         GUI.Box (Rect(0, 0, 150, 480), "Stats" );
         GUI.Box (Rect(0, 0, 150, 480), "Stats" );
         
         GUI.Box (Rect(200, 0, 130, 130), "" );
         GUI.Label (Rect(0, 0, 130, 130), "Wave:" + Wave );
     
     
     }
 }

Some of the GUI stuff dont work. and the vars dont. Sigh well thanks :(

Comment
Add comment · Show 4
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 Eric5h5 · Mar 19, 2013 at 06:32 PM 3
Share

Unity doesn't use Java. If you're trying to say "Javascript", that's a different language entirely; Java can't be used as shorthand for it. Sorry to be picky, but programmers should know this.

avatar image Graham-Dunnett ♦♦ · Mar 19, 2013 at 08:59 PM 1
Share

Some of your GUI lines are duplicated. What specific problem are you having?

avatar image AlucardJay · Mar 20, 2013 at 03:16 PM 0
Share

You cannot display Wave as an int (or float, who knows what Wave is with dynamic typecasting) in GUI, you need to convert it to a string :

 GUI.Label (Rect(0, 0, 130, 130), "Wave:" + Wave.ToString() );

this is what I gleaned from Some of the GUI stuff dont work. and the vars dont.

avatar image willkzhang · Mar 20, 2013 at 03:24 PM 0
Share

Besides clearing the confusion of Java and Javascript, you may also consider restyle your code with better indentation. :D

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by programmrzinc · Mar 20, 2013 at 02:48 PM

Most of your GUI Scripts are covering each other, like covering a piece of paper with another. You can use GUILayout, which organizes your GUI automatically. This is good because you will on have these overlapping errors.

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 logang · Mar 20, 2013 at 03:55 PM 0
Share

Okay will try that and I am fine now it turns out I had the Exit unity and go back into it to fix it.

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

15 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

Related Questions

Is that a resolution-related issue? 1 Answer

i don't understand compiler errors here... 1 Answer

How do I keep Lightmap information when copying a project? 0 Answers

Using for ... var ... in loop to access variable. 1 Answer

Trying to add 1 point to score, but it is adding 2. 2 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