Topic locked

Dynamically load xml/dat to create modeltarget looks wired in IOS

Unity Editor
August 11, 2022 - 8:21pm #1

Vuforia Version: 10.9

Unity Version: 2021.3

IOS version: 13/14

 

It works well in Editor, looks weird in IOS like IMG_0066.PNG with no error.

 

Open an Empty Scene, add ARCamera to the scene, attaching a script into it.

The xml and dat file is the default model target by Vuforia, VuforiaMars_ModelTarget

PS: OnVuforiaStarted2 function is that I directly use downloaded the xml to create modeltarget but it look the same like  IMG_0066.PNG with no error

using System.Collections;

using System.Collections.Generic;

using System.IO;

using UnityEngine;

using UnityEngine.Networking;

using Vuforia;

using static Vuforia.DataSetTrackableBehaviour;

using static Vuforia.ModelTargetBehaviour;

public class Tests : MonoBehaviour

{

    // Start is called before the first frame update

    public GameObject myModelPrefab;

    public ModelTargetBehaviour mObserverBehaviour;

    void Start()

    {

        VuforiaApplication.Instance.OnVuforiaStarted += OnVuforiaStarted;

    }

    private void OnVuforiaStarted2()

    {

        string xmlPath = Path.Combine(Application.persistentDataPath, "VuforiaMars_ModelTarget.xml");



        mObserverBehaviour = VuforiaBehaviour.Instance.ObserverFactory.CreateModelTarget(

            xmlPath,

            "VuforiaMars_ModelTarget", TrackingOptimization.DEFAULT);

        mObserverBehaviour.enabled = false;

        mObserverBehaviour.SetActiveGuideViewIndex(0);

        mObserverBehaviour.GuideViewMode = GuideViewDisplayMode.GuideView2D;

        mObserverBehaviour.enabled = true;

        Debug.Log(mObserverBehaviour);

    }

    private void OnVuforiaStarted()

    {

        StartCoroutine(download());

    }

    IEnumerator download()

    {

        string xmlPath = Path.Combine(Application.persistentDataPath, "VuforiaMars_ModelTarget.xml");

        string datPath = Path.Combine(Application.persistentDataPath, "VuforiaMars_ModelTarget.dat");

        yield return StartCoroutine(Get(xmlPath, XMLURL));

        yield return StartCoroutine(Get(datPath, DATURL));

       

        mObserverBehaviour = VuforiaBehaviour.Instance.ObserverFactory.CreateModelTarget(

            xmlPath,

            "VuforiaMars_ModelTarget", TrackingOptimization.DEFAULT);

        mObserverBehaviour.enabled = false;

        mObserverBehaviour.SetActiveGuideViewIndex(0);

        mObserverBehaviour.GuideViewMode = GuideViewDisplayMode.GuideView2D;

        mObserverBehaviour.enabled = true;

        Debug.Log(mObserverBehaviour);

    }

    IEnumerator Get(string path, string url)

    {

        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return webRequest.SendWebRequest();

        if (webRequest.isHttpError || webRequest.isNetworkError)

            Debug.Log(webRequest.error);

        else

        {

           

            File.WriteAllBytes(path, webRequest.downloadHandler.data);

            // Verify that the File has been actually stored

            if (File.Exists(path))

            {

                Debug.Log("File successfully saved at: " + path);

            }

            else

            {

                Debug.Log("Failure!! - File does not exist at: " + path);

            }

           

        }

 

    }



    // Update is called once per frame

    void Update()

    {

    }

AttachmentSize
Image icon IMG160.jpeg76.72 KB
Image icon IMG_0066.PNG54.04 KB
Platform: 

Dynamically load xml/dat to create modeltarget looks wired in IOS

September 5, 2022 - 10:42pm #2

Hey there,

 

Sorry for the delay in response. Could you share if the dataset is the standard dataset from our samples or a custom one? If it is, could you share the dataset with me through a zip file?

Also could you share a video of the issue together with information about your device specifications?

 

Kind regards,

Patrick Scheper

Vuforia Engine Product Manager

Topic locked