コード例 #1
0
        private void OnDataReceivedEvent(byte[] obj)
        {
            NetworkMessageStruct networkMessage = NetworkMessageStruct.Deserialize(obj);

            switch (networkMessage.Type)
            {
            case MessageType.ColorChange:
                DeserializeColorAndSendEvent(networkMessage.Message);
                break;

            case MessageType.WorldMap:
                Debug.Log("recieved world map");
                ARWorldMap arWorldMap = (ARWorldMap) new PackableARWorldMap(networkMessage.Message);
                RestartSessionWithWorldMap(arWorldMap);
                break;

            case MessageType.Anchor:
                Debug.Log("recieved anchor");
                ulong       trackableId1 = BitConverter.ToUInt64(networkMessage.Message, 0);
                ulong       trackableId2 = BitConverter.ToUInt64(networkMessage.Message, sizeof(ulong));
                TrackableId trackableId  = new TrackableId(trackableId1, trackableId2);
                AnchorRecieved?.Invoke(trackableId);
                break;

            case MessageType.SpawnedObject:
                DeserializeObjectSpawnAndSendEvent(networkMessage.Message);
                break;
            }
        }
コード例 #2
0
    void LoadWorldMap()
    {
        Debug.Log("Attempting to load ARWorldMap.");

        //GlobalMapManager.Instance.DownloadLatestMap(() =>
        //{
        //    var worldMap = ARWorldMap.Load(GlobalMapManager.Instance.WorldMapPath);
        //    if (worldMap != null)
        //    {
        //        Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

        //        var config = ARKitManager.Instance.DefaultSessionConfiguration;
        //        config.worldMap = worldMap;
        //        UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        //        Debug.Log("Restarting session with worldMap");
        //        ARKitManager.Instance.Session.RunWithConfigAndOptions(config, runOption);
        //    }
        //});

        var worldMap = ARWorldMap.Load(GlobalMapManager.Instance.WorldMapPath);

        if (worldMap != null)
        {
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

            var config = ARKitManager.Instance.DefaultSessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
            ARKitManager.Instance.Session.RunWithConfigAndOptions(config, runOption);
        }
    }
コード例 #3
0
    IEnumerator Load()
    {
        var sessionSubsystem = (ARKitSessionSubsystem)m_ARSession.subsystem;

        if (sessionSubsystem == null)
        {
            Log("No session subsystem available. Could not load.");
            yield break;
        }

        var DlUrl = "http://" + IP_InputField.text + ":" + _httpPort.ToString() + "/" + _GetDirectory;

        UnityWebRequest www = new UnityWebRequest(DlUrl);

        www.downloadHandler = new DownloadHandlerBuffer();
        yield return(www.SendWebRequest());

        byte[] worldMap_byte;
        var    allBytes = new List <byte>();


        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            // または、バイナリデータで結果を表示
            worldMap_byte = www.downloadHandler.data;


            Debug.Log("hash" + _GetHashedTextString(worldMap_byte));


            allBytes.AddRange(worldMap_byte);

            var worldMap_nativearray = new NativeArray <byte>(allBytes.Count, Allocator.Temp);
            worldMap_nativearray.CopyFrom(allBytes.ToArray());
            ARWorldMap worldMap;
            if (ARWorldMap.TryDeserialize(worldMap_nativearray, out worldMap))
            {
                worldMap_nativearray.Dispose();
            }

            if (worldMap.valid)
            {
                Log("Deserialized successfully.");
            }
            else
            {
                Log("Data is not a valid ARWorldMap.");
                yield break;
            }

            Log("Apply ARWorldMap to current session.");


            sessionSubsystem.ApplyWorldMap(worldMap);
        }
    }
コード例 #4
0
ファイル: ARLocationSync.cs プロジェクト: lagoluis/BeerPongAR
    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);
    }
コード例 #5
0
    public void StartSession(ARWorldMap arWorldMap = null)
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration
        {
            planeDetection        = planeDetection,
            alignment             = startAlignment,
            getPointCloudData     = getPointCloud,
            enableLightEstimation = enableLightEstimation,
            enableAutoFocus       = enableAutoFocus,
            worldMap = arWorldMap
        };

        if (detectionImages != null)
        {
            config.referenceImagesGroupName = detectionImages.resourceGroupName;
        }

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }
    }
コード例 #6
0
    public void Load(string name, string filePath)
    {
        Debug.LogFormat("Loading ARWorldMap {0}", filePath);

        var worldMap = ARWorldMap.Load(filePath);

        if (worldMap != null)
        {
            GroundPlaneManager.instance.NewSession(true);

            m_LoadedMap = worldMap;
            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);

            loadingname = name;
            isLoading   = true;
        }
    }
コード例 #7
0
ファイル: WorldMapManager.cs プロジェクト: weacw/AR_draw
    public void Load(string fileName)
    {
        var worldMap = ARWorldMap.Load(Path.Combine(Application.persistentDataPath, string.Concat(fileName, ".worldmap")));

        if (worldMap != null)
        {
            windowManager.SpawnGuideToLoad();

            loadedWorldMapName = fileName;

            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;
            relocalizing = true;
            startTime    = Time.time;

            ARKitWorldTrackingSessionConfiguration config = m_ARCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            foreach (GameObject go in GameObject.FindGameObjectsWithTag("Line"))
            {
                Destroy(go);
            }

            session.RunWithConfigAndOptions(config, runOption);
        }
    }
コード例 #8
0
    public void Load()
    {
        if (path != null)
        {
            Debug.LogFormat("Loading ARWorldMap {0}", path);
            var worldMap = ARWorldMap.Load(path);
            if (worldMap != null)
            {
                m_LoadedMap = worldMap;
                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;
                //m_TGOPlacement.Reset();
                //m_ESAPlacement.Reset();

                Debug.Log("Restarting session with worldMap");
                session.RunWithConfigAndOptions(config, runOption);
            }
        }
        else
        {
            Debug.Log("Please, specify a path");
        }
    }
コード例 #9
0
 private void RestartSessionWithWorldMap(ARWorldMap arWorldMap)
 {
     if (_arSession.subsystem is ARKitSessionSubsystem arKitSessionSubsystem)
     {
         arKitSessionSubsystem.ApplyWorldMap(arWorldMap);
     }
 }
コード例 #10
0
ファイル: ArKitWorldPersistence.cs プロジェクト: ryo0ka/MinAR
        public UniTask Load(string dirPath)
        {
            string     path     = GetPath(dirPath);
            ARWorldMap worldMap = ARWorldMap.Load(path);

            Debug.Log($"ARWorldMap loaded from {path}");

            ARKitWorldTrackingSessionConfiguration config = _camera.sessionConfiguration;

            config.worldMap = worldMap;

            const UnityARSessionRunOption runOption =
                UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            UnityARSessionNativeInterface
            .ARSessionShouldAttemptRelocalization = true;

            UnityARSessionNativeInterface
            .GetARSessionNativeInterface()
            .RunWithConfigAndOptions(config, runOption);

            Debug.Log("Restarted session with worldMap");

            return(UniTask.CompletedTask);
        }
コード例 #11
0
    public void LoadARWorldMap(ARWorldMap worldMap)
    {
        var sessionSubsystem = (ARKitSessionSubsystem)m_ARSession.subsystem;

        Debug.Log("Applying ARWM");
        sessionSubsystem.ApplyWorldMap(worldMap);
        Debug.Log("ARWM Applied");
    }
コード例 #12
0
 void OnWorldMap(ARWorldMap worldMap)
 {
     if (worldMap != null)
     {
         worldMap.Save(path);
         Debug.LogFormat("ARWorldMap saved to {0}", path);
     }
 }
コード例 #13
0
    IEnumerator Load()
    {
        var sessionSubsystem = (ARKitSessionSubsystem)m_ARSession.subsystem;

        if (sessionSubsystem == null)
        {
            Log("No session subsystem available. Could not load.");
            yield break;
        }

        var file = File.Open(path, FileMode.Open);

        if (file == null)
        {
            Log(string.Format("File {0} does not exist.", path));
            yield break;
        }

        Log(string.Format("Reading {0}...", path));

        int bytesPerFrame  = 1024 * 10;
        var bytesRemaining = file.Length;
        var binaryReader   = new BinaryReader(file);
        var allBytes       = new List <byte>();

        while (bytesRemaining > 0)
        {
            var bytes = binaryReader.ReadBytes(bytesPerFrame);
            allBytes.AddRange(bytes);
            bytesRemaining -= bytesPerFrame;
            yield return(null);
        }

        var data = new NativeArray <byte>(allBytes.Count, Allocator.Temp);

        data.CopyFrom(allBytes.ToArray());

        Log(string.Format("Deserializing to ARWorldMap...", path));
        ARWorldMap worldMap;

        if (ARWorldMap.TryDeserialize(data, out worldMap))
        {
            data.Dispose();
        }

        if (worldMap.valid)
        {
            Log("Deserialized successfully.");
        }
        else
        {
            Debug.LogError("Data is not a valid ARWorldMap.");
            yield break;
        }

        Log("Apply ARWorldMap to current session.");
        sessionSubsystem.ApplyWorldMap(worldMap);
    }
コード例 #14
0
 void OnWorldMapSerialized(ARWorldMap worldMap)
 {
     if (worldMap != null)
     {
         //we have an operator that converts a ARWorldMap to a serializableARWorldMap
         serializedWorldMap = worldMap;
         Debug.Log("ARWorldMap serialized to serializableARWorldMap");
     }
 }
コード例 #15
0
        partial void LoadExperience()
        {
            if (DataFromFile == null)
            {
                Debug.WriteLine("Map data should already be verified to exist before Load button is enabled.");
                return;
            }

            try
            {
                var data = DataFromFile;

                ARWorldMap worldMap = (ARWorldMap)NSKeyedUnarchiver.GetUnarchivedObject(typeof(ARWorldMap), data, out var err);

                if (err != null)
                {
                    Debug.WriteLine("No ARWorldMap in archive.");
                    return;
                }

                // Display the snapshot image stored in the world map to aid user in relocalizing.
                var snapshotData = worldMap.GetSnapshotAnchor()?.ImageData;

                using (var snapshot = UIImage.LoadFromData(snapshotData))
                {
                    if (snapshot != null)
                    {
                        _snapShotThumbnail.Image = snapshot;
                    }
                    else
                    {
                        Debug.WriteLine("No snapshot image in world map");
                    }
                }

                // Remove the snapshot anchor from the world map since we do not need it in the scene.
                worldMap.Anchors = worldMap.Anchors.Where(anchor => anchor.GetType() != typeof(SnapshotAnchor)).ToArray();

                var configuration = new ARWorldTrackingConfiguration
                {
                    PlaneDetection       = ARPlaneDetection.Horizontal,
                    EnvironmentTexturing = AREnvironmentTexturing.Automatic,
                    InitialWorldMap      = worldMap,
                };

                _sceneView.Session.Run(configuration, ARSessionRunOptions.ResetTracking | ARSessionRunOptions.RemoveExistingAnchors);    // Run the view's session
                isRelocalizingMap = true;
                objAnchor         = null;
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Can't unarchive ARWorldMap from file data: {ex.Message}");
                return;
            }

            Debug.WriteLine($"Success: Loaded world scene from {MapSaveURL}");
        }
コード例 #16
0
        static void _world_map_received(IntPtr worldMapPtr)
        {
            if (WorldMapReceivedEventInternal == null)
            {
                return;
            }
            var worldMap = ARWorldMap.FromPtr(worldMapPtr);

            WorldMapReceivedEventInternal(worldMap);
        }
コード例 #17
0
ファイル: MyWorldMap.cs プロジェクト: zmzmkkm/UnityStudy
    private void OnLoadClick()
    {
        UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;//重定位

        ARWorldMap newWorldMap = ARWorldMap.Load(Config.path);
        ARKitWorldTrackingSessionConfiguration configration = m_ARCameraManager.sessionConfiguration;

        configration.worldMap = newWorldMap;
        UnityARSessionRunOption option = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        Config.m_Swssion.RunWithConfigAndOptions(configration, option);
    }
コード例 #18
0
 void OnWorldMap(ARWorldMap worldMap)
 {
     if (worldMap != null)
     {
         if (path != "")
         {
             worldMap.Save(path);
             GroundPlaneManager.instance.Save(nameInput.text);
             Debug.LogFormat("ARWorldMap saved to {0}", path);
             nameInput.text = "";
         }
     }
 }
コード例 #19
0
        private async void SendWorldMapAsync()
        {
            ARWorldMap worldMap = await GetARWorldMapAsync();

            PackableARWorldMap   packableARWorldMap   = (PackableARWorldMap)worldMap;
            NetworkMessageStruct networkMessageStruct = new NetworkMessageStruct
            {
                Type    = MessageType.WorldMap,
                Message = packableARWorldMap.ARWorldMapData
            };

            SendMessage(networkMessageStruct);
        }
コード例 #20
0
 void OnWorldMap(ARWorldMap worldMap)
 {
     if (worldMap != null)
     {
         if (path != null)
         {
             worldMap.Save(path);
             Debug.LogFormat("ARWorldMap saved to {0}", path);
         }
         else
         {
             Debug.Log("Please, specify a path");
         }
     }
 }
コード例 #21
0
    public void OnMessageReceived(byte[] msg)
    {
        try
        {
            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream    serializationStream = new MemoryStream(msg, 0, msg.Length, false, false);
            //serializationStream.Write(msg, 0, msg.Length);
            object obj = bf.Deserialize(serializationStream);
            if (obj != null)
            {
                if (obj is AppState)
                {
                    AppState appState = obj as AppState;
                    Debug.Log("AppState received.");
                }
            }
            return;
        }
        catch (System.Exception)
        {
        }

        //string s = "";
        //foreach (var b in msg)
        //{
        //    s = $"{s}, {b}";
        //}
        //Debug.Log(s);
        SharedARUIManager.sharedARStatusMessage = $"MSG RECEIVED LENGTH: {msg.Length}";
        //ARWorldMap
        if (ARWorldMapController != null)
        {
            NativeArray <byte> nativeArray = new NativeArray <byte>(msg, Allocator.Persistent);
            Debug.Log("Trying to deserialize ARWM");
            bool success = ARWorldMap.TryDeserialize(nativeArray, out ARWorldMap worldMap);
            nativeArray.Dispose();
            if (success)
            {
                Debug.Log("ARWM Deserialized");
                if (worldMap.valid)
                {
                    Debug.Log("ARWM Valid");
                    ARWorldMapController.LoadARWorldMap(worldMap);
                    SharedARUIManager.sharedARStatusMessage = "SUCESS";
                }
            }
        }
    }
コード例 #22
0
 private void CompressMap(ARWorldMap map, Action <NSData, NSError> closure)
 {
     DispatchQueue.DefaultGlobalQueue.DispatchAsync(() =>
     {
         var data = NSKeyedArchiver.ArchivedDataWithRootObject(map, true, out NSError error);
         if (error == null)
         {
             closure(data, null);
         }
         else
         {
             // archiving failed
             closure(null, error);
         }
     });
 }
コード例 #23
0
    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);
    }
コード例 #24
0
    void SaveAndDisposeWorldMap(ARWorldMap worldMap)
    {
        Log("Serializing ARWorldMap to byte array...");
        var data = worldMap.Serialize(Allocator.Temp);

        Log(string.Format("ARWorldMap has {0} bytes.", data.Length));

        var file   = File.Open(path, FileMode.Create);
        var writer = new BinaryWriter(file);

        writer.Write(data.ToArray());
        writer.Close();
        data.Dispose();
        worldMap.Dispose();
        Log(string.Format("ARWorldMap written to {0}", path));
    }
コード例 #25
0
    void RestartARSessionWith(ARWorldMap worldMap)
    {
        if (worldMap != null)
        {
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

            var config = arCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
            UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, runOption);
        }
    }
コード例 #26
0
    void LoadWorldMap()
    {
        Debug.LogFormat("Loading ARWorldMap {0}", WorldMapPath);
        var worldMap = ARWorldMap.Load(WorldMapPath);

        if (worldMap != null)
        {
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

            var config = ARKitCameraManager.Instance.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
            Session.RunWithConfigAndOptions(config, runOption);

            referenceImage.GetComponent <Image>().sprite = UtilitiesCR.LoadNewSprite(ReferenceImagePath);
            referenceImage.SetActive(true);
        }
    }
コード例 #27
0
    public void LoadSerialized()
    {
        Debug.Log("Loading ARWorldMap from serialized data");
        //we have an operator that converts a serializableARWorldMap to a ARWorldMap
        ARWorldMap worldMap = serializedWorldMap;

        if (worldMap != null)
        {
            m_LoadedMap = worldMap;
            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);
        }
    }
コード例 #28
0
    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);
        }
    }
コード例 #29
0
    public void Load()
    {
        Debug.LogFormat("Loading ARWorldMap {0}", path);
        var worldMap = ARWorldMap.Load(path);

        if (worldMap != null)
        {
            m_LoadedMap = worldMap;
            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);

            myCube.transform.position = new Vector3(PlayerPrefs.GetFloat("PlayerX"), PlayerPrefs.GetFloat("PlayerY"), PlayerPrefs.GetFloat("PlayerZ"));
        }
    }
コード例 #30
0
ファイル: WorldMapManager.cs プロジェクト: zmzmkkm/UnityStudy
    /// <summary>
    /// 加载ARWorldMap
    /// </summary>
    public void Load()
    {
        Debug.LogFormat("Loading ARWorldMap {0}", Path);
#if !UNITY_EDITOR
        var worldMap = ARWorldMap.Load(Path);
        if (worldMap != null)
        {
            m_LoadedMap = worldMap;
            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);
        }
#endif
        StartCoroutine(SceneRecogOver());
    }