Setting up a Custom Scene
Last updated
Last updated
You can create your own custom scene like a basic demo. From this section you will guide you how to create a custom scene. In your own custom scene you can add preferred prefab & easy manipulation (scaling/rotating/positioning) & save scene to cloud. After that view the scene by scanning the environment.
Step 1: Create a new scene. You can give any name for your scene. After you create a scene you can only see the main camera & directional light in hierarchy. Delete main camera from scene.
Step 2: Right click on the hierarchy window and select XR -> ARSession. Same way you should add the AR Session Origin. (XR->AR Session Origin)
Step 3: Expand the AR Session Origin. You can see an AR camera there. You should also add an AR Default Point Cloud to it. Right click on AR Session origin and select XR -> AR Default Point Cloud.
Step4:AR Default Point Cloud should be a child of AR session origin. So drag & drop AR Point cloud on AR Session Origin game object.
Step 5: Select AR Session Origin, Go to Inspector & add following components to gameobject.
AR Anchor Manager
AR Plane Manager
AR Raycast Manager
AR Point Cloud Manager
For point cloud prefab in AR Point Cloud Manager Script, drag & drop AR Default Point Cloud game object from hierarchy window.
Step 6: Create a new empty game object. Name it as “SpatialAnchorConfig”. Select gameObject & in the inspector click add component & add Spatial Anchor Manager Script to it.
If you have set up spatial anchor credentials in Easy AR Spatial Anchors ->AzureSpatialAnchors.SDK->Resources-> SpatialAnchorConfig before no need to enter again in Spatial Anchor Manager Script.
Step 7: Create a new GameObject, name it “Selector”, Select gameObject & go to inspector. Drag & drop Item Selector script & Scale Rotate Handler scripts from Easy AR Spatial Anchors -> Scripts folder.
Step 8: From this step you should create your Canvas. First create an empty game object Name it as UX. Drag & drop “Canvas” prefab from Easy AR Spatial Anchors -> Prefabs folder.
Once you add canvas you can see UX like the above picture shows.
Let’s explain each game object of Canvas.
Text - This text panel shows spatial anchor state in every level. By default it disbled. If you like, you can see logs by enabling it.
Exit Button - This button redirects you to the main window of the selected scene.
ShowHidePlanesButton - This button at the top right corner of canvas. By enabling this you can turn on & turn off trackable planes from this. But you need to add plane prefab under AR Session Origin -> AR plane Manager script.
Save Button - This button is responsible for saving scene after place objects. This button pops up when placing objects.
Delete Panel - This panel popup when selecting the placed objects. If you need to delete an item touch on a relevant object for more than 5 seconds it will ask, do you want to delete this item or not.
Instruction panels - There are two instruction panels which show you and guide you how to use the app.
Main Panel - Main window appears when selected scene.
Starting Panel - All place object buttons placed in this panel
Back to Menu button - This button appears after scene save & redirects to the main window of the scene.
In the Main panel prefab, you can change Name of the scene, add subtitles, Change Icon as well.
Caption - Able to change the title of the scene.
Sub Heading - Able to change the sub heading of the scene.
Icon Image - Able to change the Icon or disable icon.
Step 9: Create a new game object. Name it “AppManager”. Add following scripts by adding components in Inspector. All these scripts are available in the Easy AR Spatial Anchors -> Scripts folder.
The scripts you need to attach are,
App State Manager
Cloud Anchor Session Manager
Scenery Persistent Manager
Scenery Placement Manager
UI Manager Demo
Placement Cursor Manager
Cloud Anchor Start
Place Object Scenery
Basic Demo Controller
Step 10 : In the UI Manager script, It asks for UI Log Output Text, Drag & drop Text game object from UX->Canvas->Text. For UI Panel Delete Item drag & drop game object from UX->Canvas->Delete Panel.
Step11 : Basic Demo controller script created for Basic demo scene in Easy AR Spatial Anchors with Azure Cloud app. Also this script controls custom scenes. For Instruction Panel 1 & Instruction Panel 2 drag & drop game objects respectively from UX->Canvas->Instruction Panel and UX->Canvas->Instruction Panel 2.
Step 12: Create a new empty game object. Name it “General Configuration”. Add General Configuration script from Easy AR Spatial Anchors -> Scripts folder to by add component in Inspector.
Step 11 : Under Visual Items in General Configuration script, there are some fields to fill. For Placement Cursor Prefab drag and drop Placement Cursor prefab from Easy AR Spatial Anchors ->Prefabs folder. For Spatial anchor group prefab drag & drop Anchor prefab from Easy AR Spatial Anchors -> Prefabs folder.
Step 12 : Next step is to apply API Configuration Items under General Configuration script. You should have to provide 2 strings under API configuration Items.
Api Url_Cloud Anchor Id - for this you should place,
<your web address>/api/anchors
If you have already created your own spatial anchor resource you can easily take your web address for above URLs. In Fundamental section, we have already discussed how to get your web address by publishing Azure web app.
Now you can place your app URL to API Urls in General Configuration scripts mentioned before.
Also we have finished creating our custom scene. Now you can build the app, steps are given in Section Build Application.