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 Gatsua · Jul 18, 2014 at 03:35 AM · buildcompile

game lost functionality after build

I am trying to make a 2D top down shooter using c# but when I build my game I lose some functionality which I do have if I run the game in the editor.

The following script is something that will do some things if the player choose to go to the next level after one is complete.

These three method calls will not execure after being built but they will in the editor:

 Time.timeScale = 0;
 
 if (Input.GetKeyDown("space")) // go to next level
 {
     Debug.Log("Space pressed");
     this.GetComponent<CharacterSelect>().LoadCharacter();
     this.GetComponent<PlayerGUI>().SetUIValues();
     this.GetComponent<GlobaGUIHandler>().SetPlayModeGUI();
     
     Debug.Log("Loading next level");
     Application.LoadLevel(Application.loadedLevel + 1);
     Debug.Log("next level loaded");
 }

LoadCharacter() does have a debug.log in its first line which I never get to after building. What am I doing wrong here?

Comment
Add comment · Show 6
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 tanoshimi · Jul 19, 2014 at 07:00 PM 0
Share

$$anonymous$$ight not be related,but I've never seen anyone call Start() on a script directly - I would encapsulate that code in another function that is called from Start(), and also called when you complete a level.

avatar image Gatsua · Jul 24, 2014 at 04:14 AM 0
Share

Ok I have edited the question after a few more hours of fighting this bug.

avatar image ikelaiah · Jul 24, 2014 at 04:37 AM 0
Share

Did you say that it works in the editor but not in the build? And why did you use Time.timeScale = 0;? Another question, where do you put these code of yours? Start()? OnGui()? Update()?

avatar image Gatsua · Jul 24, 2014 at 06:41 AM 0
Share

This is inside OnGUI() and that is why I have Time.timeScale = 0;, I want the actual game to pause while I have some victory/game over GUI screen.

avatar image Lucanio · Jul 24, 2014 at 06:52 AM 0
Share

You shouldn't put this in OnGUI, put it in update

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Gatsua · Aug 18, 2014 at 06:38 AM

This was caused by:

 Input.GetKeyDown("space")

Because the keypress was detected from the last scene after building but not when running the game in Unity.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Unity build Complete size does not match app size 0 Answers

Distribute terrain in zones 3 Answers

I making a game for windows 8 1 Answer

New C# scripts fail to build 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