OnEnable() Issue

Hello,

I’m using the Unity Pro version.

I found that my app doesn’t work properly when I build and deploy it on a device. That happened before, but I was always able to fix it by simply building my project again.

I checked my code and I found that the problem is related to the code inside the “OnEnable()” method.

I know that “OnEnable()” gets called when a gameobject is active on the scene and it’s clearly active.
It works fine on the editor, but sometimes it doesn’t work when I build my project and deploy my app on a phone or table (for both iOS and Android).

It doesn’t always happens but a significant percentage of the time that I create a build (10~20%).
Oddly the OnEnable() issue only occurs when I build a project the first time, but when I re-build it there’s never any issue.

I can’t share my project because it’s already released on the App Store.

< Current development environment >

  • Xcode: 8.2.1
  • Unity 3D engine: 5.4.4 f1
  • OSX: 10.12.3

Anyone has experienced any similar issue? Anyone knows a solution?

Thanks.

The docs state that OnEnable() can not be used as a co-routine. So you can not put OnEnable() inside for example Update().