Search Unity

Application.CommitSuicide (int mode) ??

Discussion in 'iOS and tvOS' started by donlien, Apr 16, 2010.

  1. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    I can't find any document to explain this function.

    Code (csharp):
    1. Application.CommitSuicide (int mode)
    What does this function do? :D
     
    jpthek9 likes this.
  2. iEarthHero1

    iEarthHero1

    Joined:
    Jul 28, 2009
    Posts:
    301
    I am surprised you found that code since I thought it was hidden.

    You are supposed to implement that code if Unity is formally banned by Apple.

    However, I am unsure what it does as I have not tried it myself. If you like, you may try it and I will see if I hear back from you after. : )

    Thanks.
     
  3. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    What the heck! I just tried it and unity actually accepted it. I wonder what it does?
     
  4. AmazingRuss

    AmazingRuss

    Joined:
    May 25, 2008
    Posts:
    933
    It sends out a press release to all the gaming sites telling them how horrible your game is.
     
  5. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    I wonder how many values we can choose of the parameter "mode". :D
     
  6. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    Ha ha ha... :D

    It is exposed there when I use "GoTo the Definition" function to explore Application class.
     
  7. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    This code must be creeping into my games then :?
     
  8. RobbieDingo

    RobbieDingo

    Joined:
    Jun 2, 2008
    Posts:
    484
    I was feeling suicidal, it causes a fatal error, with intent...
     
  9. donlien

    donlien

    Joined:
    Apr 13, 2009
    Posts:
    229
    mmmm... I can't imagine what's the purpose for this function? :D
     
  10. Firedan1176

    Firedan1176

    Joined:
    Dec 7, 2013
    Posts:
    48
    It's for internal use only; developers aren't supposed to use it. It's for the engine only.

    For anyone that didn't get what it does yet - Application.CommitSuicide(1) simply says an 'intentional error occured' and causes Windows to think it crashed (the Report Bug window also pops up in Unity). After you close it out, you can just simply restart Unity like it didn't happen (Hopefully you saved beforehand!).
     
  11. revapps

    revapps

    Joined:
    Jan 29, 2014
    Posts:
    5
    Here is a real example of what you can do with it:
    If you have a license check implemented within your game and find the user has a pirated version of it, you should save that to a PlayerPrefs and call Application.CommiteSuicide() to instantly crash the game. Since you saved it, you should check the value of the PlayerPrefs and crash the game every time the pirate tries to open it.
     
  12. Smilediver

    Smilediver

    Joined:
    May 5, 2011
    Posts:
    72
    For the curious: it's used by our automated tests. 0 - will simulate crash, 1 - will simulate a fatal error that Unity has caught, 2 - will call abort(). And don't ever call it with 666! ;)
     
    Last edited: Jul 14, 2014
  13. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Man I was hoping for a fun hidden gem there but 666 did nothing. :)
     
  14. Firedan1176

    Firedan1176

    Joined:
    Dec 7, 2013
    Posts:
    48
    So why exactly is it hidden and not shown up when typing it out?
     
  15. Smilediver

    Smilediver

    Joined:
    May 5, 2011
    Posts:
    72
    It's meant only for our internal usage, hence why it's not documented and marked as obsolete.
     
  16. smallbit

    smallbit

    Joined:
    Oct 3, 2013
    Posts:
    60
    I know its a late comment be I found this method very useful in testing crash reporting tools :D