UnityGeoAR is a tool for Unity3D that streamlines the development of geolocated Augmented Reality (AR) applications. It provides services for converting geo-coordinates and elevations to Unity Scene units and for aligning camera rotations between a virtual and real-world view.
Fork/Copy/Download this repository and open in the Unity Editor.
-
Make sure your app has location services permissions accepted.
-
Have a Monobehaviour that initializes an instance of
LocationUpdatesService, or alternatively use the providedLocationUpdater. -
During runtime, ensure that location updates are running before opening an AR/geolocation enabled scene. We recommend keeping the location updates running in the background until the end of the app runtime.
-
For AR-enabled scenes, first setup ARFoundation as per its instructions.
-
Make sure you have a behaviour in the scene that implements
SceneControllerBase, or use the providedARSceneController. -
At minimum, set the
sourceCRSanddestinationCRSfields ofSceneControllerBaseusing the EPSG code for the required CRS. List of EPSG codes. -
When the geolocated AR scene is first loaded, make sure to set the
locationSourceCRSAtSceneLoad,locationDestinationCRSAtSceneLoad, andcompassHeadingAtSceneLoadfields ofSceneControllerBase. Optionally, also set the elevation at start, if using elevations. -
If using your own implementation of
SceneControllerBase, also make sure to offset the Y rotation of the AR Session Origin GameObject (that is the parent of the ARCamera) bycompassHeadingAtSceneLoaddegrees. -
Now you can use the methods provided in
SceneControllerBase.WorldToUnityServiceto reproject objects geolocated near the user's location, and place them in the scene around the camera.
You can always have a look at the included ARNavigation examples (Found in Assets > Scenes > AR-Navigation) to see usages of the UnityGeoAR tools. ARNavigation draws a path that users can follow in AR to navigate between two points.
-
AR-Navigation_TestSceneimplements a geocoder and routing service to set a destination (requires an API key from OpenRouteService, you can store API keys in aAPIKeyContainerscriptable object:Create > ScriptableObjects > API Keys Container) -
AR-Navigation_PresetRoutesreads from preset routes available during compile time. Preset routes can be provided as .txt files containing series of waypoints in (y,x) format. Have a look atPresetRouteSelectorHandlerfor a preset routes parser. Sample preset routes are stored inAssets > Resources
To test the example ARNavigation app, build the app using the following scenes included in the build settings, and run on a mobile device.
