Search Unity

AR Foundation build error on WebGL: SpatialTracking does not exist in the namespace UnityEngine

Discussion in 'Handheld AR' started by HE_MarkT, Feb 19, 2019.

  1. HE_MarkT

    HE_MarkT

    Joined:
    Feb 15, 2019
    Posts:
    1
    I'm working on a multiplatform game (WebGL and mobile), that will feature an AR feature in the mobile version. But I've been having trouble building the WebGL version without completely removing the AR Foundation package and all references.

    When I open the AR Foundation example project and attempt to create a WebGL build, I get the following compiler error:

    Code (CSharp):
    1. Library\PackageCache\com.unity.xr.arfoundation@1.0.0-preview.22\Runtime\AR\ARSessionOrigin.cs(3,19): error CS0234: The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
    As far as I can tell, Unity doesn't have any way to exclude packages on a platform-dependent basis, or I would simply exclude the entire AR package from my buildsdefinition. I don't actually need any of the AR Foundation features, I simply need it to stop throwing errors when I build for WebGL so I don't have to maintain 2 completely separate projects, or uninstall/reinstall the package every time I switch platforms.

    Is there any work-around for this, or is this going to be fixed in an upcoming version? Thanks.
     
    coder89 and Saicopate like this.
  2. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    17
    I faced the exact same problem with Windows/UWP build target. There are more packages having issues with cross-platform. Unfortunately, it seems that either Package Manager or packages themselves are not production-ready yet.
     
  3. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    639
    AR Foundation is for mobile platforms Android and IOS only because they have ARKit/ARCore capabilities - there are various browser restrictions on camera access and various other problems like that causing ARFoundation to not be available for a WebGL export.
     
  4. Shirzad

    Shirzad

    Joined:
    Dec 8, 2016
    Posts:
    16
    You need too update all packages under package manager.
     
    Last edited: Apr 29, 2019
  5. cbrig25

    cbrig25

    Joined:
    Aug 18, 2015
    Posts:
    2
    For Unity 2019.1.4 when using mapbox to remove the error SpatialTracking does not exist. First go to Project settings - player and ensure in the XR settings that ARCore Supported is ticked. Then go to package manager and install XR Legacy Input Helpers.
     
  6. MarblXR70

    MarblXR70

    Joined:
    Sep 3, 2017
    Posts:
    2
    Even with Unity 2018.4.10 and the latest of AR Foundation preview 6, there is still the same error when building for WebGL: Library\PackageCache\com.unity.xr.arfoundation@1.5.0-preview.6\Runtime\AR\ARSessionOrigin.cs(3,19): error CS0234: The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    For a multiplatform app where AR is just optional, we still want to maintain a common codebase including iOS, Android and WebGL, so this was a breaker for us using the AR Foundation package. It is understood that AR is not working for WebGL, but the AR Foundation package should still compile without errors for WebGL with the help of #ifdefs...

    I ended up coping the ARFramework folder from Packages to Assets, removing the AR Foundation package via package manager and doing the necessary ifdefs there...
    To make it compile, I had to manually edit "Packages/manifest.json" and add: "com.unity.xr.arsubsystems": "2.2.0-preview.3", as ARFoundation code requires a later version of this normally hidden package which is not accessable via package manager.
     
unityunity