Forum Discussion

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

OVRManager Disappears when Spawning Prefab

I have been having some real problems with OVRManager. It's way more finicky than OVRDevice.

I have found that using 'Instantiate' and 'Network.Instantiate' to spawn ANY prefab with the OVRManager script it, spawns clones with the OVRManager component missing!

I have tried it with multiple OVRManager components in one game object, in different locations etc. Every time, I have found that in the clone, the OVRManager is simply stripped out.

Someone please help!

Just to make it clear, I have tested this in different scenes and even different projects. The result is the same. I have never seen this before

I am using Oclus SDK 0.4.3 on Unity 4.5.5p2.

Edit: I am aware I only need one OVRManager in a scene, and that it does not need to be attached to a camera controller/rig, and that I can just toggle it on and off. Never-the-less I would like to know what the cause of this might be.

3 Replies

Replies have been turned off for this discussion
  • Tylo's avatar
    Tylo
    Honored Guest
    I just wanted to say that this is still happening to me.

    And even if I try to do an AddComponent<OVRManager> after the gameobject is Instantiated, it mysteriously returns null and does not work.

    I've never run into this behavior in Unity before when adding components.
  • Tylo's avatar
    Tylo
    Honored Guest
    Like many things in Unity, this seems to be caused by a "trying to do too many things in one Frame".

    OVRManager is a singleton class. Something inside of it prevents it from being added to more than one GameObject.

    If you try to Destroy and Spawn a new GameObject with a new OVRManager, then the GameObject will attempt to spawn before the old OVRManager is destroyed.

    My usual solution to situations like these, if I can get away with it, is to make my Spawn method a Coroutine and tell it to wait until end of frame.

    This guarantees that the Destroy call will resolve and that my Spawn method will work on the start of the next frame.
  • I think you can try renaming the OVRManager function "Start" to "OnEnable". See if that helps.