Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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:
    21
    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:
    21
    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.
     
  3. TechnicalArtist

    TechnicalArtist

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

    Aravindhan92

    Joined:
    Jul 10, 2018
    Posts:
    1
    can we create ARCORE based webgl build in unity?
     
    MarshallVisions and alexrau like this.
  5. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,875
    No, and please dont use such giant bold font its horrible to read and comes across as attention seeking, in a bad way.
     
  6. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
    So is Web AR possible using Unity?
     
    AnkitRitz007 likes this.
  7. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    It would be nice to at least know 'why' we can't do this yet - is there a limitation of AR Foundation? Or something we can work around?
     
  8. AkamaruDesign

    AkamaruDesign

    Joined:
    Dec 17, 2016
    Posts:
    13
    in fact it has to do with hardware limitations as far as I know, ar foundation uses not only the camera but other systems and sensors of the phone, such as gyro, compass, accelerometer, etc ...
    and that is the main reason why even on some phones it doesn't work, and it can't be tested in the editor, at least not without unity remote.
     
    Fenikkel likes this.
  9. iTouchi

    iTouchi

    Joined:
    Feb 20, 2020
    Posts:
    3
    Any news on AR foundation getting support on the web? Now that safari also supports WebGL 2.0 with iOS15 and WebXR (immersive web at W3C) is working on making WebXR standards?
     
    mr-Tartan and Blarp like this.
  10. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Any news about this topic?
     
  11. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,444
    It's not like Apple is supporting WebXR any time soon with Safari unless there is some news on this I missed.
     
  12. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    872
    There are several Unity Plugins that allow AR in WebGL:
    https://forum.unity.com/threads/ar-for-webgl-with-unity.1412541/


    Current list of Assets:
     
    Last edited: Jun 9, 2023
  13. Red_Dragon69

    Red_Dragon69

    Joined:
    Sep 7, 2015
    Posts:
    90
    For everyone looking for a real WebXR solution, check out Needle engine, which uses Unity as Editor and Typescript as scripting backend for threejs based WebXR solutions - https://engine.needle.tools/docs/ - and it's free for non-commercial use.