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 shadowkiller0071 · Aug 01, 2014 at 09:09 AM · javascript2d gamecrashdebug

Unity crashes on playing in editor and playing after build.

On build it plays a sound and black screens. If I try to play in the editor the entire thing (excluding monodevelop) simply crashes. I have absolutely no idea how to fix this and don't want to re do the entire thing (worked on it for a while). It has a sizable script which just started crashing. Here is the script. #pragma strict

 var pointValue = 1;
 var currentScore : int = 0;
 var cube1 : GameObject;
 var cube2 : GameObject;
 var cube3 : GameObject;
 var cube4 : GameObject;
 var cube5 : GameObject;
 var cube6 : GameObject;
 var cube1a : GameObject;
 var cube2b : GameObject;
 var cube3c : GameObject;
 var cube4d : GameObject;
 var cube5e : GameObject;
 var cube6f : GameObject;
 private var random : int;
 var offsetY : float = 40;
 var sizeX : float = 100;
 var sizeY : float = 40;
 
 function OnGUI () {
     GUI.Box (new Rect (Screen.width/2-sizeX/2, offsetY, sizeX, sizeY), currentScore + " Doritos with your dew");
 }
  
  
 function Update () 
 {
 if (Input.GetKeyDown ("w")) {
 cube1.active = false;
 cube2.active = true;
 cube3.active = false;
 cube4.active = false;
 cube5.active = false;
 cube6.active = false;
 if (cube2b.active) {
 currentScore += pointValue;
 audio.Play();
 }
 } if (Input.GetKeyDown ("q")) {
 cube1.active = true;
 cube2.active = false;
 cube3.active = false;
 cube4.active = false;
 cube5.active = false;
 cube6.active = false;
 if (cube1a.active) {
 currentScore += pointValue;
 audio.Play();
 }
 } if (Input.GetKeyDown ("e")) {
 cube1.active = false;
 cube2.active = false;
 cube3.active = true;
 cube4.active = false;
 cube5.active = false;
 cube6.active = false;
 if (cube3c.active) {
 currentScore += pointValue;
 audio.Play();
 }
 } if (Input.GetKeyDown ("a")) {
 cube1.active = false;
 cube2.active = false;
 cube3.active = false;
 cube4.active = true;
 cube5.active = false;
 cube6.active = false;
 if (cube4d.active) {
 currentScore += pointValue;
 audio.Play();
 }
 } if (Input.GetKeyDown ("s")) {
 cube1.active = false;
 cube2.active = false;
 cube3.active = false;
 cube4.active = false;
 cube5.active = true;
 cube6.active = false;
 if (cube5e.active) {
 currentScore += pointValue;
 audio.Play();
 }
 } if (Input.GetKeyDown ("d")) {
 cube1.active = false;
 cube2.active = false;
 cube3.active = false;
 cube4.active = false;
 cube5.active = false;
 cube6.active = true;
 if (cube6f.active) {
 currentScore += pointValue;
 audio.Play();
 }
 } 
 
 random = Random.Range(0, 6); 
 }
 
 do {
 cube1a.active = true;
 cube2b.active = false;
 cube3c.active = false;
 cube4d.active = false;
 cube5e.active = false;
 cube6f.active = false;
 } while (!(Input.GetKeyUp ("q") || random > 1.1));
 do {
 cube1a.active = false;
 cube2b.active = true;
 cube3c.active = false;
 cube4d.active = false;
 cube5e.active = false;
 cube6f.active = false;
 } while (!(Input.GetKeyUp ("w") || random > 2.1));
 do {
 cube1a.active = false;
 cube2b.active = false;
 cube3c.active = true;
 cube4d.active = false;
 cube5e.active = false;
 cube6f.active = false;
 } while (!(Input.GetKeyUp ("e") || random > 3.1));
 do {
 cube1a.active = false;
 cube2b.active = false;
 cube3c.active = false;
 cube4d.active = true;
 cube5e.active = false;
 cube6f.active = false;
 } while (!(Input.GetKeyUp ("a") || random > 4.1));
 do {
 cube1a.active = false;
 cube2b.active = false;
 cube3c.active = false;
 cube4d.active = false;
 cube5e.active = true;
 cube6f.active = false;
 } while (!(Input.GetKeyUp ("s") || random > 5.1));
 do {
 cube1a.active = false;
 cube2b.active = false;
 cube3c.active = true;
 cube4d.active = false;
 cube5e.active = false;
 cube6f.active = true;
 } while (!(Input.GetKeyUp ("d") || random > 6.1));
 
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiwasi · Aug 01, 2014 at 09:12 AM

You really should rewrite the whole thing. Nothing in this script is worth salvaging.

The problem is your while loops that will never terminate. Input.GetKeyUp will not switch based on any of the terms inside the while loop.

You need to learn to use arrays as well.

My condolences that you worked on this for so long.

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 shadowkiller0071 · Aug 02, 2014 at 02:07 AM 0
Share

Thank you. If that is the case then I suppose I'll just figure out a way to do what I want without loops.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Filing and debuging web plugin crashes 1 Answer

Can't find script controlling mouse clicks 0 Answers

boolean issue 1 Answer

Please help me make a health system with GUI. I cant do it! 3 Answers

Online Player Position 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