We use the existing WindowManager and LocationPinViewHandler to open the panels required for the path preview.
Example 1: Passing Location Pin Information from the Scene
Selecting a Location Pin from the Creator Portal
The first thing we need to do is acquire a value from the location pin that we can reference. You can choose from the following location pin values: id, name, description, or notes.
In this example, we'll use the "notes" section, located under the "Advanced Settings" when selecting the location pins.
Modifying the SDK Code
Modifying the "Dashboard" Scene
You can add a new function to save a value to the PlayerPrefs that can be fetched when the "ARMapSession" scene is opened.
publicvoidOpenLocationPinPreview(string destinationValue){ // Find the MapsInfoManager GameObjectGameObject mapsInfoManagerObject =GameObject.Find("MapsInfoManager");if (mapsInfoManagerObject !=null) { // Attempt to get the MapsInfoManager componentMapsInfoManager mapsInfoManager =mapsInfoManagerObject.GetComponent<MapsInfoManager>();if (mapsInfoManager !=null) { // Set destination value in PlayerPrefsPlayerPrefs.SetString("NavToValue", destinationValue);PlayerPrefs.Save(); // Start AR sessionmapsInfoManager.StartARSession(true); } }}
Modifying the "ARMapSession" Scene
In the file "Assets/ARway/ViewerMode/2_Scripts/SDK/ARMapLoader.cs" add the following function:
Then, include the function call at the end of LoadLocationpinContent, around line 111.
...
#region WayPointContent
foreach (Waypoint3d tour in arContent.waypoints3ds)
{
ContentStorageManager.Instance.LoadNavigationTour(tour);
}
#endregion
+ CheckForNavTo();
}
...
Then in that same file, add the following to line #5:
usingSystem.Collections.Generic;
Then, on line #15, add the following line PlayerPrefs.SetInt("ArwayKit.Viewer.InstructionRequired", 0); to the OnEnable function. This is to hide the pop-up that appears after entering the map, as we will be proceeding directly to the instant navigation instead.
From there, if there is a matching value in the "notes" section of the Location Pin it will open the Location Pin Path Preview after the QR code is scanned, and the map content is loaded.
Example 2: Using the Anchor Description
Edit the Description of an Anchor to Include a Location Pin Name
In the Creator Portal Studio, select an Anchor, and then in the left menu, enter the following: InstantNav: locationPinName. We will use the "InstantNav:" portion as the identifier so that only if the keyword is present in the anchor that has been scanned, it will use the locationPinName to choose the instant navigation location pin. This means that you can replace "locationPinName" with the name of your location pin. Once you've added the description, click the "Save" button at the bottom, and then publish your map.
The location pin for instant navigation matches what has been set in the anchor description.
Modifying the SDK Code
In the file "Assets/ARway/ViewerMode/2_Scripts/SDK/ARMapLoader.cs" add the following function:
publicvoidCheckForNavTo(){string keyword ="InstantNav:";string lastQRCodeScanId =ArwayMapController.Instance.LastScanQRID(); // Create a dictionary for faster lookupDictionary<string,LocationPinUi> locationPinsWithID =ContentStorageManager.Instance.m_LocationPinsWithID;foreach (Anchor m_Anchor inArwayMapController.MapData.data.metadata.anchors) {if (m_Anchor.id== lastQRCodeScanId &&m_Anchor.description.StartsWith(keyword)) { // Extract location pin name directly without using Substringstring locationPinName =m_Anchor.description.Substring(keyword.Length).Trim();foreach (var kvp in locationPinsWithID) {LocationPinUi locationPinUi =kvp.Value;if (locationPinUi.locationPin.name== locationPinName) {WindowManager.Instance.OpenPanel("LocationpinViewerPanel");LocationpinViewer.Instance.OpenLocationDetails(locationPinUi);LocationpinViewer.Instance.GetDirection();return; // Exit loop if found } } } }}
Then in that same file, add the following to line #5:
usingSystem.Collections.Generic;
Then, on line #15, add the following line PlayerPrefs.SetInt("ArwayKit.Viewer.InstructionRequired", 0); to the OnEnable function. This is to hide the pop-up that appears after entering the map, as we will be proceeding directly to the instant navigation instead.
Then at the bottom of the file, on line #139, add the line to the end of the LoadMapContent function, and the file will look like this:
...#regionWayPointContentforeach (Waypoint3d tour inarContent.waypoints3ds) {ContentStorageManager.Instance.LoadNavigationTour(tour); }#endregionCheckForNavTo();}
Then you can build your app. When you add the keywords to the anchor description in the Creator Portal Studio, you can enable the instant navigation functionality in your customized app.