void Start() { // Get a reference to the SpatialAnchorManager component (must be on the same gameobject) if (UseOwnAnchorManager) { cloudManager = ASAManager; } else { //Add new Spatial Anchor Manager to the gameobject gameObject.AddComponent <SpatialAnchorManager>(); cloudManager = GetComponent <SpatialAnchorManager>(); cloudManager.AuthenticationMode = AuthenticationMode.ApiKey; cloudManager.SpatialAnchorsAccountId = ASAAccountId; cloudManager.SpatialAnchorsAccountKey = ASAAccountKey; cloudManager.SpatialAnchorsAccountDomain = ASAAccountDomain; } if (cloudManager == null) { Debug.Log("There is no Spatial Anchor Manager Component on the same gameobject as the anchor module one. Please add one."); } else { Debug.Log("CloudManager ist da"); } // Register for Azure Spatial Anchor events cloudManager.AnchorLocated += CloudManager_AnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); }
void Start() { spatialAnchorManager = FindObjectOfType <SpatialAnchorManager>(); anchorConverter = FindObjectOfType <AnchorConverter>(); aRTapHandler = FindObjectOfType <ARTapHandler>(); anchorLerper = FindObjectOfType <AnchorLerper>(); }
// Start is called before the first frame update async void Start() { //have to Task Delay at the start in order to give ARSession time to set up properly await Task.Delay(3000); spatialAnchorManager = GetComponent <SpatialAnchorManager>(); aRAnchorManager = FindObjectOfType <ARAnchorManager>(); //if the session doesn't exist, create session if (spatialAnchorManager.Session == null) { await spatialAnchorManager.CreateSessionAsync(); } //add AnchorLocated event so when the session detects an anchor, it does what we want it to spatialAnchorManager.AnchorLocated += CloudAnchorManager_AnchorLocated; debugText.text = "\nSession Created"; //begin the session await spatialAnchorManager.StartSessionAsync(); //request the sesnsor permissions for wifi and geolocation -- then configure requestSensorPermissions(); configureSensors(); debugText.text += "\nSession Started"; debugText.text += "\nID: " + spatialAnchorManager.SpatialAnchorsAccountId; debugText.text += "\nKey: " + spatialAnchorManager.SpatialAnchorsAccountKey; }
void Awake() { appStateManager = FindObjectOfType <AppStateManager>(); generalConfiguration = FindObjectOfType <GeneralConfiguration>(); spatialAnchorManager = FindObjectOfType <SpatialAnchorManager>(); SetupCloudSessionAsync(); }
void Start() { // Get a reference to the SpatialAnchorManager component (must be on the same gameobject) cloudManager = GetComponent <SpatialAnchorManager>(); // Register for Azure Spatial Anchor events cloudManager.AnchorLocated += CloudManager_AnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); }
// Start is called before the first frame update void Start() { spatialAnchorManager = GetComponent <SpatialAnchorManager>(); ARSession aRSession = FindObjectOfType <ARSession>(); aRAnchorManager = FindObjectOfType <ARAnchorManager>(); anchorManager = FindObjectOfType <AnchorManager>(); ARSession.stateChanged += AnchorConverter_SessionStateChange; tutorialManager.gameObject.SetActive(true); }
void Start() { // Get a reference to the SpatialAnchorManager component (must be on the same gameobject) cloudManager = GetComponent <SpatialAnchorManager>(); // Register for Azure Spatial Anchor events cloudManager.AnchorLocated += CloudManager_AnchorLocated; anchorLocateCriteria = new AnchorLocateCriteria(); coarseRelocalizationSettings = Resources.Load <CoarseRelocalizationSettings>("CoarseRelocalizationConfig"); }
/// <inheritdoc/> protected override void OnManagedDispose() { base.OnManagedDispose(); if (spatialAnchorManager != null) { Debug.Log("SpatialAnchorsCoordinateService: Cleaning up SpatialAnchorManager."); StopSession().FireAndForget(); GameObject.Destroy(spatialAnchorManager); // Destroying the SpatialAnchorManager should destroy the session. spatialAnchorManager = null; } }
public SpatialAnchorsCoordinateService(GameObject parent, SpatialAnchorsConfiguration spatialAnchorsConfiguration) { this.gameThreadSynchronizationContext = SynchronizationContext.Current; this.parent = parent; this.spatialAnchorsConfiguration = spatialAnchorsConfiguration; if (this.parent != null) { Debug.Log("SpatialAnchorsCoordinateService: Creating a CustomSpatialAnchorManager."); SpatialAnchorConfig config = CustomSpatialAnchorConfig.Create(spatialAnchorsConfiguration.AccountId, spatialAnchorsConfiguration.AccountKey); spatialAnchorManager = this.parent.AddCustomSpatialAnchorManager(config); StartSession().FireAndForget(); } }
public static async Task <bool> ExportAnchors(this WindowsMRAnchorSubsystem wmrrp, Stream output) { bool ret = false; #if ENABLE_WINMD_SUPPORT try { Debug.Log($"Getting Spatial Anchor Transfer Manager Access"); var access = await SpatialAnchorTransferManager.RequestAccessAsync(); if (access != SpatialPerceptionAccessStatus.Allowed) { Debug.Log($"Access check failed with {access}"); return(ret); } Debug.Log($"Getting Spatial Anchor Store"); var spatialAnchorStore = await SpatialAnchorManager.RequestStoreAsync(); if (spatialAnchorStore == null) { return(ret); } Debug.Log($"Setting up stream"); var stream = output.AsOutputStream(); Debug.Log($"Getting saved anchors"); var anchors = spatialAnchorStore.GetAllSavedAnchors(); if (anchors == null || anchors.Count == 0) { Debug.Log("No anchors to exort!!!"); } else { Debug.Log("Exporting anchors..."); ret = await SpatialAnchorTransferManager.TryExportAnchorsAsync(anchors, stream); Debug.Log(ret ? "SUCCESS" : "FAILURE"); } } catch (Exception e) { Debug.Log(e); ret = false; } #else Debug.LogError("This API is only available for use in UWP based applications."); #endif //ENABLE_WINMD_SUPPORT return(ret); }
/// <summary> /// Initializes static members of the <see cref="MixedReality"/> class. /// Attempts to initialize the world coordinate system from a given spatial anchor. /// If no spatial anchor is given, it attempts to load a default spatial anchor. /// If the default spatial anchor is not found (e.g., if the app is being run for the first time), /// a stationary frame of reference for the world is created at the current location. /// </summary> /// <param name="worldSpatialAnchor">A spatial anchor to use for the world (optional).</param> /// <param name="regenerateDefaultWorldSpatialAnchorIfNeeded">Optional flag indicating whether to regenerate and persist default world spatial anchor if currently persisted anchor fails to localize in the current environment (default: false).</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> /// <remarks> /// This method should be called after SK.Initialize. /// </remarks> public static async Task InitializeAsync(SpatialAnchor worldSpatialAnchor = null, bool regenerateDefaultWorldSpatialAnchorIfNeeded = false) { if (!SK.IsInitialized) { throw new InvalidOperationException("StereoKit is not initialized. Call SK.Initialize before calling MixedReality.InitializeAsync."); } // Create the spatial anchor helper SpatialAnchorHelper = new SpatialAnchorHelper(await SpatialAnchorManager.RequestStoreAsync()); InitializeWorldCoordinateSystem(worldSpatialAnchor, regenerateDefaultWorldSpatialAnchorIfNeeded); // By default, don't render the hands or register with StereoKit physics system. Input.HandVisible(Handed.Max, false); Input.HandSolid(Handed.Max, false); }
/// <summary> /// Gets an anchor <see cref="Pose"/> from the specified native anchor <see cref="IntPtr"/>. /// </summary> /// <param name="anchorPointer">The anchor pointer.</param> /// <returns><see cref="Pose"/>.</returns> /// <exception cref="System.InvalidOperationException">Invalid anchor pointer. Can't get the pose.</exception> private static Pose GetPose(IntPtr anchorPointer) { if (anchorPointer == IntPtr.Zero) { throw new InvalidOperationException("Invalid anchor pointer. Can't get the pose."); } ARAnchor referencePoint = SpatialAnchorManager.ReferencePointFromPointer(anchorPointer); if (referencePoint == null) { Debug.Log("Didn't find the anchor"); return(Pose.identity); } return(new Pose(referencePoint.transform.position, referencePoint.transform.rotation)); }
#pragma warning disable CS0618 #pragma warning disable CS1998 public static async Task <bool> ImportAnchors(this WindowsMRAnchorSubsystem wmrrp, Stream input) { bool ret = false; #if ENABLE_WINMD_SUPPORT try { var access = await SpatialAnchorTransferManager.RequestAccessAsync(); if (access != SpatialPerceptionAccessStatus.Allowed) { return(ret); } var spatialAnchorStore = await SpatialAnchorManager.RequestStoreAsync(); if (spatialAnchorStore == null) { return(ret); } var anchors = await SpatialAnchorTransferManager.TryImportAnchorsAsync(input.AsInputStream()); foreach (var kvp in anchors) { spatialAnchorStore.TrySave(kvp.Key, kvp.Value); } ret = true; } catch (Exception e) { Debug.Log(e); ret = false; } #else Debug.LogError("This API is only available for use in UWP based applications."); #endif //ENABLE_WINMD_SUPPORT return(ret); }
/// <summary> /// Sets up all required references to create and find anchors /// </summary> private void ConfigureReferences() { Log(nameof(ConfigureReferences)); CloudManager = GetComponent <SpatialAnchorManager>(); CloudManager.SessionUpdated += CloudManager_SessionUpdated; CloudManager.AnchorLocated += CloudManager_AnchorLocated; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; CloudManager.SpatialAnchorsAccountKey = Config.AccountKey; CloudManager.SpatialAnchorsAccountId = Config.AccountId; CloudManager.SpatialAnchorsAccountDomain = Config.AccountDomain; Log($"ASA Id {Config.AccountId}", true); Log($"ASA Key {Config.AccountKey}", true); Log($"ASA Domain {Config.AccountDomain}", true); anchorLocateCriteria = new AnchorLocateCriteria(); status = new AsaStatus(); //info: DemoScript also checks a reference for an input manager here. }
/// <summary> /// 初期化処理を実施します /// </summary> public void Start() { try { // Azure Spatial Anchors管理用のコンポーネントを取得します。 cloudManager = GetComponent <SpatialAnchorManager>(); // Azure Spatial Anchorsサービスを呼出したときに発生するイベントを割り当てます。 // Azure Spatial Anchorsから取得したアンカー情報をもとにアンカーの設置が完了した際に発生するイベント cloudManager.AnchorLocated += CloudManager_AnchorLocated; // Azure Spatial Anchorsから取得したアンカー設置処理がすべて完了すると呼ばれるイベント cloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; // Azure Spatial Anchorsへの検索条件を設定するクラスのインスタンス化 anchorLocateCriteria = new AnchorLocateCriteria(); } catch (Exception e) { Debug.Log(e); throw; } }
/// <summary> /// Sets up all required references to create and find anchors /// </summary> private void ConfigureReferences() { #if !UNITY_EDITOR Log(nameof(ConfigureReferences), true); CloudManager = GetComponent <SpatialAnchorManager>(); CloudManager.SessionUpdated += CloudManager_SessionUpdated; CloudManager.AnchorLocated += CloudManager_AnchorLocated; CloudManager.LocateAnchorsCompleted += CloudManager_LocateAnchorsCompleted; CloudManager.LogDebug += CloudManager_LogDebug; CloudManager.Error += CloudManager_Error; CloudManager.SpatialAnchorsAccountKey = Config.AccountKey; CloudManager.SpatialAnchorsAccountId = Config.AccountId; CloudManager.SpatialAnchorsAccountDomain = Config.AccountDomain; Log($"ASA Id {Config.AccountId}", true); Log($"ASA Key {Config.AccountKey}", true); Log($"ASA Domain {Config.AccountDomain}", true); anchorLocateCriteria = new AnchorLocateCriteria(); #else Log("ASA Config skipped due to wrong platform"); #endif status = new AsaStatus(); }
private async Task GetStoreAsync() { anchorStore = await SpatialAnchorManager.RequestStoreAsync(); LoadAnchors(); }
private void Start() { cloudManager = GetComponent <SpatialAnchorManager>(); SetGraphEnabled(true); }
/// <summary> /// Setup references to other components on this GameObject. /// </summary> private void Awake() { m_cloudSpatialAnchorManager = GetComponent <SpatialAnchorManager>(); }