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 Oct 03, 2017 at 08:58 AM by Bilelmnasser for the following reason:

The question is answered, right answer was accepted

This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by Bilelmnasser · Jul 15, 2014 at 05:49 PM · c#crashgame

Crash the entire game

i want to know how to crash my entire game in case of failed loading of resources ? and how to personalize message or message box for it ? thank you

Comment
Add comment · Show 3
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 Anti-Social Fred · Jul 15, 2014 at 05:56 PM 0
Share

Do you mean something like...

     Sprite s = null;
 
     void StartUp()
     {
         LoadResources();
         CheckForFail();
     }
 
     void LoadResources()
     {
         s = Resources.Load("sprite") as Sprite;
     }
 
     void CheckForFail()
     {
         if (s == null)
         {
             Debug.LogError("Loading failed! Quitting game!"); // Change to GUI so the player can see it
             Application.Quit; 
         }
     }

?

avatar image AndyMartin458 · Jul 15, 2014 at 06:07 PM 0
Share

As an aside, that won't work in the Editor.

avatar image Bilelmnasser · Jul 15, 2014 at 08:27 PM 0
Share

i don't want to do that for every texture or resource, i want a global game crush but thanks anyway, this can helpful in some case

3 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by markzpot · Jul 15, 2014 at 06:23 PM

This will quit the application:

 Application.Quit;

http://docs.unity3d.com/ScriptReference/Application.Quit.html

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 Bilelmnasser · Jul 15, 2014 at 08:25 PM 0
Share

ok that's what i look for, a global crush of my game when a loading of any resources is failed textures,hardwares etc... thank you guys will hit +1 :)

avatar image
1

Answer by Firedan1176 · Jul 15, 2014 at 06:40 PM

Another solution that is not documented is using:

 Application.Suicide(1);

Keep in mind this should NOT be used in the editor unless you saved your project. If you're curious, it just makes Unity crashes and warns Windows that it "crashed". The Unity Error Report window also pops up.

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
avatar image
1

Answer by Kiwasi · Jul 15, 2014 at 06:42 PM

You could always throw an exception. This will work in the editor, and will behave very similar to any other error during GamePlay.

Link to documentation

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

27 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 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

Unity Editor Crashes On Play Because of Import Script 1 Answer

Unity Crashes Every time I Try To Run This Code 1 Answer

Victory menu is not working HELP 1 Answer

Distribute terrain in zones 3 Answers

Multiple Cars not working 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