Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
vanlalhriata's avatar
vanlalhriata
Honored Guest
3 years ago

OVRManager singleton check destroys original instance

OVRManager is a singleton that checks its instance field on Awake, and destroys itself if its not null. This happens in the InitOVRManager method. And this is fine.

But OnDestroy also sets the static OVRManagerinitialized field to false. So whenever a duplicate OVRManager destroys itself as part of the singleton check, the static OVRManagerinitialized is false, causing the original OVRManager's Update loop to run InitOVRManager (which has the singleton check). But now the static instance is not null so the original instance destroys itself as part of the singleton check.

I realize this is possibly a bug and a fix would be to set OVRManagerinitialized back to true after the DestroyImmediate line. I was wondering if there's something I'm missing or if there's another workaround without having to modify the source.