Multi-platform Handheld AR

During GDC 2018, we talked about providing a multi-platform AR solution so that we could democratize AR development:

Today we announced the first step in that endeavor - ARFoundation: https://blogs.unity3d.com/2018/06/15/multi-platform-handheld-ar-in-2018-part-1/

Here is a summary:

ARFoundation currently exposes these features:

  • Planar surface detection
  • Depth data represented as point clouds
  • Performant pass-thru rendering
  • Reference points to aid in anchoring virtual objects to the physical world
  • Estimates for average color temperature and brightness
  • Tracking device position and orientation in physical space
  • Utilities for scaling content properly in AR
  • Raycasting against plane and depth data

Get started by installing 2018.1 with iOS and/or Android support, getting the sample projects from arfoundation-samples (they include ARFoundation and its required platform specific parts in their manifest), and deploying to your iOS and/or Android device.

Read up on the documentation, and come to this forum for any questions or comments. Weā€™re also working on more tools that work with ARFoundation, and integrating more recent features of the AR platforms.

So give this a try for your AR projects and give us feedback here! Happy developing!

3 Likes

I cannot seem to find ScaledContent, is it coming soon? :slight_smile: Thanks

Support for scale is still there, but we decided to remove the explicit ā€œscaleā€ field from the ARSessionOrigin, since all it did was uniformly set the transform of its GameObject. Thereā€™s no example in the sample repo yet, but all you have to do is set the scale of the transform of the GameObject with the ARSessionOrigin, and it will do the same thing as you may have seen in ARInterface.

Cheers,
Tim

Good Job! It seems I cannot iterate in editor (like in AREditorInterface), am I missing something?

hey, first of all itā€™s good to have this package finally! :slight_smile:

A question: How is camera permission managed for Android? Is it still on ARCore side? Previously I was able to subscribe to AndroidPermissionsManager event form GoogleARCore to get notified about user permission. But now ARCore API is not exposedā€¦ Is there any way?

Thanks Tim

Does it still only ā€œtransformā€ the camera? We changed the ā€œPlace On planeā€ script, to find our gameobject by tag and move it.

When iĀ“m testing, it seems i only move part of my scene. And that dosent make sense if the camera is the one moving? Is it becourse i need to anchor the full scene?

Hope this makes sense, thanks!

Support for in-Editor remoting and simulation is coming soon (it will be in another package). Stay tuned!

1 Like

If the app has been configured as AR Optional (instead of AR Required, see https://docs.unity3d.com/Packages/com.unity.xr.arcore@1.0/manual/index.html#build-settings ), then camera permissions are requested when you try to start an AR Session (in ARFoundation, this happens when the ARSession component is enabled). There is no callback (maybe there should be?), but you can query the current state of camera permissions with ARSubsystemManager.cameraSubsystem.IsPermissionGranted()

The ā€œPlaceOnPlaneā€ sample component places itself on the plane, that is, it moves the content. This is to show how to place very simple content, like a cube, onto the plane using a raycast.

If you want to move the entire camera rig (and all trackables) to make complex content (e.g., terrain) appear on a plane (but without actually moving the content itself), then you should look at https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@1.0/api/UnityEngine.XR.ARFoundation.ARSessionOrigin.html#UnityEngine_XR_ARFoundation_ARSessionOrigin_MakeContentAppearAt_Transform_Vector3_Quaternion_

This is conceptually similar to this method in ARInterface: https://github.com/Unity-Technologies/experimental-ARInterface/blob/master/Assets/UnityARInterface/Scripts/ARController.cs#L92

Thanks alot! Are you still planning on sharing your sample projects, from March 19 talk? :slight_smile:

Weā€™ll be adding samples to the existing github repo over time. It may not be exactly those samples, but something to show similar concepts, yes.

1 Like

I swapped out the Unity ARKit 1.5 plugin with the new AR Foundation and builds worked great until I went to create an archive build in Xcode for publishing to Test Flight. Then I keep getting stuck on this error:

ld: bitcode bundle could not be generated because ā€˜/Users/[UserName]/[ProjectName]/[BuildName]/Libraries/UnityARKit.a(RootViewSize.o)ā€™ was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64

Any ideas? Thanks!

What about other ar features? Will them be supported? Like face tracking, worldmap, reference image, reference objects of ARKit? Like cloud anchors , augmented image of ARCore?

Yes the idea is that these features will be implemented into ARFoundation in a multiplatform manner soon.

Hmm, looks like we need to build the ARKit plugin with -fembed-bitcode to allow that. We donā€™t do that currently; Iā€™ll look into it for the next release.

3 Likes

Appreciate it!

Iā€™m really happy to see things are moving along with AR Framework! Iā€™m doing some preliminary investigation before I replace the Experimental ARInterface in my project with AR Framework.

Does the Raycasting stuff work at all in the editor? With ARInterface I could aim AR Root around in the scene to raycast against planes in the ARGameObject layer. But the AR Default Plane in AR Framework doesnā€™t work the same way so Iā€™m having a hard time figuring out how I can do simple raycast tests from the AR Camera in the editor.

Not currently. In-Editor simulation is coming (via another package).

2 Likes

Thanks Tim. I ended up using a separate plugin /UniAndroidPermission/ because I need to request camera permissions independently for a non AR-scene.

BTW. Whatā€™s up with ARAnchors? Are they not needed anymore or not currently supported?

BTW2. I filed a bug report - > quitting ARscene causes Android app to hang and throw a leakage warning in Android Monitor, easly reproductuble with sample scene + added non-AR scene (all attached in bug report).

Whatā€™s the best way to remove ARPlaneā€™s after theyā€™ve been created and stop generating new ones?

Hereā€™s what Iā€™ve tried so far:

public class RemovePlanes : MonoBehaviour
{
    [SerializeField]
    private ARPlaneManager m_ARPlaneManager;

    private List<ARPlane> m_planes = new List<ARPlane>();
  
    public void RemoveAllPlanes()
    {
        if (m_ARPlaneManager.planeCount == 0)
        {
            Debug.Log("** no planes to remove");
            return;
        }

        // get all the planes in the scene
        m_ARPlaneManager.GetAllPlanes(m_planes);

        // and disable their game objects
        for (int i = 0; i < m_planes.Count; i++)
        {
            Debug.Log("Removed "+m_planes[i].name);
            m_planes[i].gameObject.SetActive(false);
        }

        // disable the plane manager so we stop generating new planes
        m_ARPlaneManager.enabled = false;
    }
}

The planes are disabled, plane generation stops and physics objects that were placed on top of the AR Planes fall through. So far so good.

But then in another script Iā€™m aligning an object to the AR Planes with a Raycast. After removing the planes with the above script, my ā€œhit objectā€ in the following script still moves around on the plane as if itā€™s still totally there.

    void Update ()
    {
        var hits = s_RaycastHits;
        Ray ray = new Ray(m_camera.position, m_camera.forward);

        if(m_SessionOrigin.Raycast(ray, hits, TrackableType.PlaneWithinPolygon))
        {
            m_hitObject.position = hits[0].pose.position;       
        }
    }

    List<ARRaycastHit> s_RaycastHits = new List<ARRaycastHit>();

So it seems that the physical Plane has been removed, but there is still some aspect of the plane there that the Raycast is hitting. This is probably ok, but it makes me think that Iā€™m not removing the Planes correctly.