Commit 608fce80 authored by Jérémy Lacoche's avatar Jérémy Lacoche
Browse files

remove some log, wait for arsession to be ready for loading arkit world map

parent 900e2250
Loading
Loading
Loading
Loading
+1 −7
Original line number Original line Diff line number Diff line
@@ -8,11 +8,6 @@ public class WorldAnalysisARFoundationCoroutineHelper : MonoBehaviour


    private void Awake()
    private void Awake()
    {
    {
        // If there is an instance, and it's not me, delete myself.


        Debug.Log("HERE SINGLETON AWAKE");

        if (Instance != null && Instance != this)
        if (Instance != null && Instance != this)
        {
        {
            Destroy(this);
            Destroy(this);
@@ -25,7 +20,6 @@ public class WorldAnalysisARFoundationCoroutineHelper : MonoBehaviour


    public void StartACoroutine(IEnumerator coroutine)
    public void StartACoroutine(IEnumerator coroutine)
    {
    {
        Debug.Log("HERE SINGLETON");
        StartCoroutine(coroutine);
        StartCoroutine(coroutine);
    }
    }
}
}
 No newline at end of file
+36 −19
Original line number Original line Diff line number Diff line
@@ -119,6 +119,8 @@ public class WorldAnalysisARFoundationModuleARKitWorldMap : WorldAnalysisARFound
    {
    {
        foreach (var trackedAnchor in eventArgs.updated)
        foreach (var trackedAnchor in eventArgs.updated)
        {
        {
            Debug.Log("Anchor found  " +trackedAnchor.trackableId.ToString());

            if (trackedAnchor.trackableId.ToString() == m_arfoundationAnchorTrackableId)
            if (trackedAnchor.trackableId.ToString() == m_arfoundationAnchorTrackableId)
            {
            {
                /// look for an anchor with the trackable Id correspond to the ETSI ARF trackable name
                /// look for an anchor with the trackable Id correspond to the ETSI ARF trackable name
@@ -137,12 +139,14 @@ public class WorldAnalysisARFoundationModuleARKitWorldMap : WorldAnalysisARFound
    {
    {
        if (url.Length > 0)
        if (url.Length > 0)
        {
        {
             Debug.Log("Load AR Map from URL");
            LoadWorldMapFromURL(url);
            LoadWorldMapFromURL(url);
            // don't check if url is valid
            // don't check if url is valid
            return true ;
            return true ;
        }
        }
        else 
        else 
        {
        {
             Debug.Log("Load AR Map locally");
            string localMap = Application.persistentDataPath + "/ARkitWorlMap.map";
            string localMap = Application.persistentDataPath + "/ARkitWorlMap.map";
            if (File.Exists(localMap))
            if (File.Exists(localMap))
            {
            {
@@ -191,8 +195,20 @@ public class WorldAnalysisARFoundationModuleARKitWorldMap : WorldAnalysisARFound
    /// <returns>coroutine</returns>
    /// <returns>coroutine</returns>
    public IEnumerator CoroutineLoadWorldMap(string mapPath)
    public IEnumerator CoroutineLoadWorldMap(string mapPath)
    {
    {
        while (ARSession.state == ARSessionState.CheckingAvailability || ARSession.state == ARSessionState.None ||ARSession.state == ARSessionState.SessionInitializing)
        {
            // wait for ar session to be ready
            yield return null ;
        }

        ARSession session = Component.FindAnyObjectByType<ARSession>() ;
        ARSession session = Component.FindAnyObjectByType<ARSession>() ;
        ARKitSessionSubsystem sessionSubsystem = (ARKitSessionSubsystem)session.subsystem;
        ARKitSessionSubsystem sessionSubsystem = (ARKitSessionSubsystem)session.subsystem;
        if (sessionSubsystem == null)
        {
            Debug.Log("Cannot load map: no ARKitSessionSubsystem");
        }
        else 
        {
            FileStream file;
            FileStream file;
            file = File.Open(mapPath, FileMode.Open);
            file = File.Open(mapPath, FileMode.Open);
            const int bytesPerFrame = 1024 * 10;
            const int bytesPerFrame = 1024 * 10;
@@ -218,4 +234,5 @@ public class WorldAnalysisARFoundationModuleARKitWorldMap : WorldAnalysisARFound
            UpdateTrackableInfoWithPose(Vector3.zero, Quaternion.identity); // before trying to find an anchor: default pause is origin of the map
            UpdateTrackableInfoWithPose(Vector3.zero, Quaternion.identity); // before trying to find an anchor: default pause is origin of the map
        }
        }
    }
    }
}
#endif
#endif
 No newline at end of file