Search Unity

AR Foundation and WebGL (I know it's not support, just read. :) )

Discussion in 'AR/VR (XR) Discussion' started by Philip-ACN, Feb 8, 2019.

  1. Philip-ACN

    Philip-ACN

    Joined:
    Oct 25, 2018
    Posts:
    19
    Lets get it out of the way first. I know AR Foundation won't work on WebGL!
    What I'd like to know if theres a way to build an app for WebGL which has ARFoundation elements in, when you don't use the AR features.

    Allow me to explain..

    I have a simple AR app.
    It works on Mobile as expected, but I've coded it so when ran in the editor or built for windows, it'll disable the AR system and use a non AR system instead. This way I can write the same app that'll work on mobile and standalone.

    I'd like to deploy it to a website without having to create a separate version of the app. (To ensure no version gets left behind)

    I've tried wrapping #if !UNITY_WEBGL around all the AR code so it's not compiled, but it looks like the actual source code is being included. (Specifically the ARSessionOrigin.cs file)
     
  2. Philip-ACN

    Philip-ACN

    Joined:
    Oct 25, 2018
    Posts:
    19
    Ok, I've found a solution to this. (I thought I'd post the issue anyway in case anyone else had this issue, they could follow this advice.)

    What I did when deploying to WebGL (in addition to the #if !UNITY_WEBGL wrappings mentioned above) was to simply disable the gameobject containing the AR Subsystems, (AR Session, and AR Session Origin) then remove the AR Foundation package. (Leaving the ARKit and ARCore packages.)

    This allowed me to build the project as normal. Once I deployed the web version, I re-added the AR Foundation package and continued as normal.
     
    3d_Artist1987 likes this.
  3. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    700
    Thanks for sharing knowledge.
     
  4. Aravindhan92

    Aravindhan92

    Joined:
    Jul 10, 2018
    Posts:
    1
    can we create ARCORE based webgl build in unity?
     
  5. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,620
    No, and please dont use such giant bold font its horrible to read and comes across as attention seeking, in a bad way.
     
    xLeo and AnaRojo_6dlab like this.