- Home /
Application.CommitSuicide?
Hi, i was typing up a script when I came along Application.CommitSuicide. I've tried looking into what it is but I can't find anything about it. Does anybody know what it's for? Thanks.
http://forum.unity3d.com/threads/application-commitsuicide-int-mode.46495/
Edit : I'm bored, and saw this topic is still on the front page of the questions list, so I guess I'll add my two cents to go along with the info from that old forum topic without bumping it...
Rules of Application.CommitSuicide() :
Application.CommitSuicide(int mode) summons $$anonymous$$ira, the Shinigami that Light Yagami became after his demise.
The (int mode) is actually an optional parameter since Application.CommitSuicide() is the original function.
If you don't pass the int parameter, you'll simply die from a heart attack within 40 seconds after calling the function.
If you do pass the int parameter, different numbers mean different things. From 0-9, these are 9 different ways to die (undocumented, and no survivors to tell us what kind of death the numbers decided; but rumor has it that zero will be a heart attack just like without passing an int, and that one of the other numbers has $$anonymous$$ira write up an interesting way for you to kill yourself which screws up the whole deal and is quite possibly a far worse way to die; but it'll still be easier to kill yourself this way since you're being compelled by a supernatural force to do so).
For three digits AFTER the first digit, any number between 0-365 will indicate the number of days to pass after calling the function before you die. If you pass any three-digit number greater than 365, it will indicate that you want it to be randomized 0-366 (exclusive of max). One year is the longest time you can set, so if you want to wait longer then you need to use a coroutine that will call Application.CommitSuicide() after a certain amount of time. (Personally, I think if you're going to wait any longer than maybe until the next holiday or your wedding anniversary or something, then you might as well just hold off on calling this function altogether because you might change your $$anonymous$$d at some point.)
Entering a zero or a one after the three-digit day will decide a day/night-time death (if you only want to enter a single or double-digit day, then do it as 001 or 021, etc; left-pad with zero's), any single digit entered here that is greater than 1 will result in a random choice between day/night.
Answer by Firedan1176 · Jul 13, 2014 at 12:18 AM
Quick answer: Application.CommitSuice(1); causes a message telling the user that an intentional error has occurred (such as if unity crashed, etc). The Report Error window then pops up, and Unity crashes. You can simply restart Unity afterwards (hopefully you save beforehand!).
I am not familiar with the int modes you can put in the parenthesis.
This is a simple answer for anyone in the future reading.
Answer by Bunny83 · Jul 12, 2014 at 11:39 PM
Two things about that function:
It's not documented. That's a general sign that you shouldn't use it at all.
It's marked with
Obsolete("For internal use only")
. So it's even more clear that you shouldn't use it and that you actually shouldn't be able to use it since it's only ment for internal use.
What it actually does, doesn't matter. It might simply exit the editor / application with an error code (by using ExitProcess or TerminateProcess on windows machines). If you really want to know what happens, try it.
Answer by revapps · Jul 13, 2014 at 12:55 AM
It would be useful for doing a license check on your game. If you find that someone pirated the game, you would save that and instantly close the game whenever its opened.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Walking animation problem. 0 Answers
Problems with java script. 1 Answer
How to have animation play correctly 1 Answer
Calling a C# function from a Javascript 3 Answers