Search Unity

ARFoundation - Instantiating ARSession and ARSessionOrigin dynamically

Discussion in 'AR/VR (XR) Discussion' started by AnthonyReddan, Jan 14, 2019.

  1. AnthonyReddan

    AnthonyReddan

    Joined:
    Feb 27, 2018
    Posts:
    39
    Is it necessary for ARSession and ARSessionOrigin (and its child camera) to live in the scene file? I'd like to have ARSession and ARSessionOrigin fit into our bootstrap sequence. Part of that involves delaying their creation a little bit.

    I tried a test where I instantiate them and add them as children of another game object in the scene (on Awake). This fails miserably on Android (haven't yet tested iOS) where it seems to render garbage. It doesn't ask for camera permissions either.

    I seem to be able to have these as children of another game object in the scene at build time and that works just fine so the problem arises only when we try to dynamically create them. Any ideas?
     
  2. AnthonyReddan

    AnthonyReddan

    Joined:
    Feb 27, 2018
    Posts:
    39
    It seems I was able to get it working by instantiating them even later (instead of in Awake - Start). Not sure why but I won't question it :D!
     
    gibbrish123 likes this.
  3. gibbrish123

    gibbrish123

    Joined:
    Feb 29, 2020
    Posts:
    8
    Hi Anthony, I'm trying to do something similar, could you provide some details on how you went about it?? It'll be most helpful... thanks and great that you figured it out.