public IEnumerator Relocate(byte[] receivedBytes) { //start relocation statusGO.SetActive(true); statusText.text = "Start relocalize.."; ARWorldMap arWorldMap = ARWorldMap.SerializeFromByteArray(receivedBytes); //Use the AR Session manager to restart session with received world map to sync up ExampleARSessionManager easm = FindObjectOfType <ExampleARSessionManager>(); easm.StartSession(arWorldMap); //check tracking state and update UI while (_arTrackingState != ARTrackingState.ARTrackingStateLimited || _arTrackingStateReason != ARTrackingStateReason.ARTrackingStateReasonRelocalizing) { yield return(null); //wait until it starts relocalizing } statusText.text = "Relocalizing... look around the area"; while (_arTrackingState != ARTrackingState.ARTrackingStateNormal) { yield return(null); } statusText.text = "Relocalized!"; yield return(null); statusGO.SetActive(false); yield return(null); }
void LoadSerializedWorldMap(byte[] worldMapInBytes) { ARWorldMap worldMap = ARWorldMap.SerializeFromByteArray(worldMapInBytes); Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent); UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true; var config = m_ARCameraManager.sessionConfiguration; config.worldMap = worldMap; UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking; Debug.Log("Restarting session with worldMap"); session.RunWithConfigAndOptions(config, runOption); }
public IEnumerator Relocate(byte[] receivedBytes) { //start relocation ARWorldMap arWorldMap = ARWorldMap.SerializeFromByteArray(receivedBytes); //Use the AR Session manager to restart session with received world map to sync up ExampleARSessionManager easm = FindObjectOfType <ExampleARSessionManager>(); easm.StartSession(arWorldMap); //check tracking state and update UI while (_arTrackingState != ARTrackingState.ARTrackingStateLimited || _arTrackingStateReason != ARTrackingStateReason.ARTrackingStateReasonRelocalizing) { yield return(null); //wait until it starts relocalizing } while (_arTrackingState != ARTrackingState.ARTrackingStateNormal) { yield return(null); } }