添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
力能扛鼎的领结  ·  C语言 ...·  1 年前    · 
爱玩的金鱼  ·  vcxproj.filters 文件 | ...·  1 年前    · 

Hey there,

I have a Problem with OnDestroy. So I have boxes which spawn loot which is triggered in the box script via OnDestroy. The loot when being spawn Registers itself to a gridfield on which it has been spawned.

If I Close the application / Stop the Editor Player, I get tons of exception Errors.

The Problem seems to be that when I Close the application, OnDestroy is being triggered which tries to spawn loot which cannot be registered to a gridfield since These also have been destroyed via quitting the application.

Is there any way to check if an application has been quit or not ?

Something like If(!Application.Quit){ do stuff…}

You’re probably familiar with the basic MonoBehaviour hooks: Update, Start, Awake, and so on.

There are quite a few others . One of them is OnApplicationQuit . You could use that function to set a flag in your script:

bool quitting;
void OnApplicationQuit() {
    quitting = true;
void OnDestroy() {
    if (quitting) {
        //application is quitting; don't spawn more stuff
    } else {
        //application is running, proceed normally

I would love to know if there’s an easier way to check that, but at least it’s possible.