text stringlengths 0 1.11k |
|---|
Save your project and your scene. |
From the File Menu, select Project Settings. |
Select Oculus, and then select the Android tab. |
Check the Checklist for warnings or errors or warnings. Choose Apply All or Fix to have Unity resolve them. |
Check the Project Setup Tool |
Save and Run the Project |
From the File menu, choose Save to save your scene and Save Project to save the project. |
From the File menu, choose Build Settings to open the Build Settings* window. |
Make sure your Meta Quest headset is the selected device in the Run Device dropdown. If you don’t see your headset in the list, click Refresh. |
Click Add Open Scenes to add your scene to the build. Deselect and remove any other scenes from the selection window. |
Click the Build and Run button to launch the program onto your headset. |
Try Out the App |
When you first start the app, you’ll see that each controller displays a capsule. The left controller shows a green capsule, and the right controller shows a red capsule. Green capsules are saved to local storage when they are created, but red ones are never saved. |
Press the left index trigger one or more times to create small green capsules. The anchor for each capsule is automatically saved to the headset. |
Press the right index trigger one or more times to create small red capsules. These anchors are not saved to the headset. |
Press the X button to destroy all capsules. All capsules are removed from your view. |
Press the A button to load all saved capsules. Only green capsules reappear. |
Press the Y button to erase all green anchors from local storage. The green capsules remain on the screen. |
Press the X button to destroy all capsules. All capsules are removed from your view. |
Press the A button to load all saved capsules. Because you erased them, no green capsules reappear. |
Spatial Anchors Added at Runtime |
Appendix: The Full AnchorTutorialUIScript.cs File. |
using System; |
using System.Collections; |
using System.Collections.Generic; |
using System.Linq; |
using Unity.VisualScripting; |
using UnityEngine; |
using UnityEngine.Serialization; |
using UnityEngine.UIElements; |
using static OVRSpatialAnchor; |
//using static UnityEditor.Progress; |
public class AnchorTutorialUIManager : MonoBehaviour |
{ |
/// <summary> |
/// Anchor Tutorial UI manager singleton instance |
/// </summary> |
public static AnchorTutorialUIManager Instance; |
[SerializeField] |
private GameObject _saveableAnchorPrefab; |
public GameObject SaveableAnchorPrefab => _saveableAnchorPrefab; |
[SerializeField, FormerlySerializedAs("_saveablePreview")] |
private GameObject _saveablePreview; |
[SerializeField, FormerlySerializedAs("_saveableTransform")] |
private Transform _saveableTransform; |
[SerializeField] |
private GameObject _nonSaveableAnchorPrefab; |
public GameObject NonSaveableAnchorPrefab => _nonSaveableAnchorPrefab; |
[SerializeField, FormerlySerializedAs("_nonSaveablePreview")] |
private GameObject _nonSaveablePreview; |
[SerializeField, FormerlySerializedAs("_nonSaveableTransform")] |
private Transform _nonSaveableTransform; |
private OVRSpatialAnchor _workingAnchor; |
private List<OVRSpatialAnchor> _allSavedAnchors; //we've written these to the headset (green only) |
private List<OVRSpatialAnchor> _allRunningAnchors; //these are currently running (red and green) |
private System.Guid[] _anchorSavedUUIDList; //simulated external location, like PlayerPrefs |
private int _anchorSavedUUIDListSize; |
private const int _anchorSavedUUIDListMaxSize = 50; |
Action<OVRSpatialAnchor.UnboundAnchor, bool> _onLoadAnchor; |
private void Awake() |
{ |
if (Instance == null) |
{ |
Instance = this; |
_allSavedAnchors = new List<OVRSpatialAnchor>(); |
_allRunningAnchors = new List<OVRSpatialAnchor>(); |
_anchorSavedUUIDList = new System.Guid[_anchorSavedUUIDListMaxSize]; |
_anchorSavedUUIDListSize = 0; |
_onLoadAnchor = OnLocalized; |
} |
else |
{ |
Destroy(this); |
} |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.