Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    14
    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:
    14
    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:
    673
    Thanks for sharing knowledge.