Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AR Foundation scene starts using camera skybox

Discussion in 'AR' started by enhawk, Nov 15, 2018.

  1. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    In the recent version of AR Foundation, for less than a second, a skybox will appear first, then the camera shows.
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    Which scene?
     
  3. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I think I may have found the culprit to this issue, I am subscribing like so:

    Code (CSharp):
    1. void OnEnable()
    2.     {
    3.  
    4.             UnityEngine.XR.ARFoundation.ARSubsystemManager.planeAdded += AddPlane;
    5.     }
     
    Last edited: Nov 20, 2018
  4. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I'll try to comment out all plane related stuff and run it again, noticed that this started happening after subscribing to events.

    Is there anything that would slow down the AR camera initialising? I'm not doing anything else special. On iOS.
     
  5. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    Do you have an ARPlaneManager? Plane detection is enabled or disabled based on whether there are any subscribers, and it is expected that you subscribe to its events rather than the ARSubsystemManager directly.
     
    enhawk likes this.
  6. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    do you have some example code we can use for this? I just guessed how this works tbh from sifting through references.
     
  7. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I'm going in like this:

    Code (CSharp):
    1. using UnityEngine.XR;
    2. using UnityEngine.Experimental.XR;
    3. using UnityEngine.XR.ARExtensions;
    4. using UnityEngine.XR.ARFoundation;
    5.  
    6.  
    7. public class Sample : MonoBehaviour {
    8.  
    9.     public ARPlaneManager arpm;
    10.  
    11.     void OnEnable()
    12.     {
    13.             UnityEngine.XR.ARFoundation.ARSubsystemManager.planeAdded += AddPlane;
    14.  
    15.     }
    16.     void Start () {
    17.   arpm = GameObject.FindObjectOfType<UnityEngine.XR.ARFoundation.ARPlaneManager>();
    18.     }
    19.     public void AddPlane(PlaneAddedEventArgs eventArgs)
    20.     {
    21.         StartCoroutine(PlaneWait(eventArgs));
    22.  
    23.     }
    24.     IEnumerator PlaneWait(PlaneAddedEventArgs eventArgs)
    25.     {
    26.         yield return new WaitForEndOfFrame();
    27.         yield return new WaitForEndOfFrame();
    28.         ARPlane thisPlane = arpm.TryGetPlane(eventArgs.Plane.Id);
    29.  
    30.         if (thisPlane.boundedPlane.Alignment == PlaneAlignment.Vertical)
    31.         {
    32.             print("vertical");
    33.         }
    34.         if (thisPlane.boundedPlane.Alignment == PlaneAlignment.Horizontal)
    35.         {
    36.             print("horizontal");
    37.         }
    38.     }
    39.  
    With the standard SampleScene contents