Search Unity

How to load two or more ARworld map on a single tracking?

Discussion in 'AR' started by zyonneo, May 21, 2019.

  1. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
    I am trying to load two or more worldmaps which I saved earlier.Starting I load one worldmap,later after covering some distance I load second worldmap and next worldmap after some distance.The problem I faced is when I load the second worldmap the prefabs loaded on the first map changes their position (resets) and loaded at different positons.Since the second map does not contain any position of the models of the first map's prefab.Without resetting how to load the other maps along with the first map?
    Code (CSharp):
    1. public void Load(string flname)
    2.     {
    3.  
    4.    
    5.        
    6.  
    7.         //Loading file from persistent path
    8.    
    9.    
    10.         Debug.LogFormat("Loading ARWorldMap {0}", Loadpath);
    11.         var worldMap = ARWorldMap.Load(Loadpath);
    12.  
    13.    
    14.         if (worldMap != null)
    15.         {
    16.             m_LoadedMap = worldMap;
    17.             Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);
    18.  
    19.             UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;
    20.  
    21.             var config = m_ARCameraManager.sessionConfiguration;
    22.             config.worldMap = worldMap;
    23.            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
    24.  
    25.             Debug.Log("Restarting session with worldMap");
    26.            session.RunWithConfigAndOptions(config, runOption);
    27.            // StopPlaneDetection();
    28.  
    29.  
    30.         }
    31.         else
    32.         {
    33.             Debug.Log("No World Map loaded");
    34.         }
    35.  
    36.  
    37.  
    38.  
    39.     }
    After That I call
    Code (CSharp):
    1. Load(path+FileName2);//for second world map
    2. Load(path+FileName3);//for third world map