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 DayyanSisson · Oct 23, 2011 at 07:40 AM · buildbugscenegamebuild-error

Standalone Build Issues

In Unity, in the Game Scene, everything works perfectly fine. But then I make a build of it, and the GUI isn't working. I have a bar, telling the player how much ammo he has, and as the player shoots, the ammo goes down, and the bar gets smaller. It works fine in the game scene, but even when I update my build, it doesn't work. Is this a bug?

Here's the script (no variables):

 function OnGUI () {
     
     var hitGround = Nuke.hit;
     
     if(canShoot){
     GUI.backgroundColor = Color.blue;    
     GUI.contentColor = Color.white;    
     GUI.skin = skin;    
     GUI.Button(Rect(10,500,bulletsLeft*5, 30),bulletsLeft.ToString("f1"));
     }
     else if(!canShoot && Time.time % 2 < 1){
     GUI.backgroundColor = Color.red;    
     GUI.contentColor = Color.white;    
     GUI.skin = skin;    
     GUI.Button(Rect(10,500,bulletsLeft*5, 30),("Gun Jam"));
     }
     if(gameTime >= 90){
     GUI.backgroundColor = Color.yellow;
     GUI.contentColor = Color.white;
     GUI.skin = skin;
     nukePassfield = GUI.TextField (Rect (10, 10, 200, 20), nukePassfield, 25);
     }
     
     if(shot && Time.time % 2 < 1 && !hitGround){
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.white;
     GUI.skin = skin;
     GUI.Button(Rect(10,10,Screen.width,Screen.height),("Prepare for Fallout"));
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.white;
     GUI.skin = skin;
     GUI.Button(Rect(10,10,Screen.width,Screen.height),("Prepare for Fallout"));
     }
     
     if(Time.time % 10 < 1 && hitGround){
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.white;
     GUI.skin = skin;
     GUI.Button(Rect(10,10,Screen.width,Screen.height),("Game Over"));
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.white;
     GUI.skin = skin;
     GUI.Button(Rect(10,10,Screen.width,Screen.height),("Game Over"));
     }
     
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.white;
     GUI.skin = skin;
     
     if(!nukeUnlocked) return;
             if(GUI.Button(Rect(10,400,50, 30),("Nuke"))){
                 Instantiate(nuke, nukeSpawnPoint.position, nukeSpawnPoint.rotation);
                 Instantiate(nuke, nukeSpawnPointTwo.position, nukeSpawnPointTwo.rotation);
                 shot = true;
             }
 }

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 syclamoth · Oct 23, 2011 at 07:44 AM 0
Share

Well, maybe not. Depends on exactly how the thing works! There are certain things which work in the editor, which do not work in builds. Usually, there are warnings in the documentation against that kind of thing, but sometimes it's just unexpected. Could you post the specific code for the ammo bar so we can have a look at it?

avatar image LegionIsTaken · Oct 23, 2011 at 08:34 AM 0
Share

That does tend to happen from time to time.

avatar image RetepTrun · Oct 27, 2011 at 04:17 PM 0
Share

How does it not work? (ie: Does not display at all? Displays but nothing happens?)
What are you building it for?

maybe its just positioned off the screen?

avatar image DayyanSisson · Oct 27, 2011 at 06:30 PM 0
Share

It displays, but it doesn't update. Whenever the player fires, the number of bullets is subtracted by one, and the total number shown in the GUI goes down. The GUI displays how many bullets the player has. I think it might not have to do with the GUI part of it though, because the rest of the GUI worked when I added some things in. It might be this code:

 if(Input.GetButtonDown("Fire1") && Time.time > nextFire && canShoot) {
         nextFire = Time.time + fireRate;    
     Instantiate (projectile, transform.position, transform.rotation);           
     Instantiate (muzzleFlash, transform.position, transform.rotation);       
     hasFired = true;
     JamCheck(); 
 PlaySoundOne();      
     }
 
 if(Input.GetButtonDown("Fire2") && Time.time > nextFire && spitfire && canShoot) {
         nextSpitfire = Time.time + spitfireFireRate;
     Instantiate (projectile, transform.position, transform.rotation);    
     Instantiate (muzzleFlash, transform.position, transform.rotation);        
     hasFiredSpitfire = true;
     SpitfireJamCheck ();
 PlaySoundTwo();  
     }      
 
     if(hasFired) {            
     bulletsLeft -= 1;
     bulletShotCount += 1;    
     }
     
     if(hasFiredSpitfire) {        
     bulletsLeft -= 3;    
     bulletShotCount += 3;    
     spitfireShotCount += 1;    
     }     

The problem with this scrip is the hasfired part of the code, and it's not updating.

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity is broken completely 1 Answer

Distribute terrain in zones 3 Answers

Cloud Build fails with Analytics.AnalyticsEvent (2019.2.1f) 1 Answer

Objects are visible through terrain 3 Answers

Why there are bugs in the build version even though there was none in the scene/editor? 0 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