Log in or register to post comments

xml & dat loaded successfully, but app stops

April 10, 2013 - 7:57pm #1

Hi, 

I use Vuforia 2.0.31 and  Unity 4.1.2 with loading dataset's xml/dat files to create iOS app.

It is loaded successfully that the app loads dataset's xml/dat files, but after loaded, the app stops while create dataset(app is also paused).

Of course, this phenomena is occured only with my script loading dataset, not occured without the script.

The Script is below:

 

using UnityEngine;

using System.Collections;

using System.IO;



public class LoadingManager : MonoBehaviour {



IEnumerator Start () {



WWW requestDAT = new WWW("http://myurl");

yield return requestDAT;



WWW requestXML = new WWW("http://myurl");

yield return requestXML;



File.WriteAllBytes(Application.persistentDataPath + "/ar.dat" , requestDAT.bytes);

File.WriteAllBytes(Application.persistentDataPath + "/ar.xml" , requestXML.bytes);



string dataSetPath = Application.persistentDataPath + "/ar.xml";



Debug.Log ("dataset path:" + dataSetPath);

LoadAndActivateDataset(dataSetPath);

}



void LoadAndActivateDataset(string dataSetPath){



if(TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) == null){

Debug.Log("generates Image Tracker.");

TrackerManager.Instance.InitTracker(Tracker.Type.IMAGE_TRACKER);

}



if(!DataSet.Exists(dataSetPath, DataSet.StorageType.STORAGE_ABSOLUTE)){

Debug.LogError("the dataset path: " + dataSetPath + " does not exist.");

return;

}else{

Debug.Log ("the dataset path:" + dataSetPath + " exists.");

}



ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);



DataSet dataSet = imageTracker.CreateDataSet();



if (!dataSet.Load(dataSetPath,DataSet.StorageType.STORAGE_ABSOLUTE)){

            Debug.LogError("Failed to load data set " + dataSetPath + ".");

            return;

        }else{

Debug.Log(dataSetPath + " Loaded.");

}



StateManager stateManager = TrackerManager.Instance.GetStateManager();



        foreach (TrackableBehaviour tb in stateManager.GetTrackableBehaviours()){



            GameObject go = tb.gameObject;



            go.AddComponent<DefaultTrackableEventHandler>();



Debug.Log("Completely success LoadAndActiveDataset.");



GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);



cube.transform.parent = tb.transform;

        cube.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);

        cube.transform.localPosition = new Vector3(0.0f, 0.35f, 0.0f);

        cube.transform.localRotation = Quaternion.identity;

        cube.active = true;

        tb.gameObject.active = true;



        }



        imageTracker.ActivateDataSet(dataSet);

    }



}

 

Could you tell me what the code wrong?

Thank you,

 

eugene

xml & dat loaded successfully, but app stops

April 12, 2013 - 3:09am #4

The same script functioned well in another project 3 months ago.

What was different about this project?

 

Are you able to resume the app in any way after it stops?

 

N

xml & dat loaded successfully, but app stops

April 11, 2013 - 7:01pm #3

Thank you for your reply.

 

This is the only issue of our app, other method has no problem completely.

As you know, app does not stop in Unity Editor(because Application.persistentDataPath has difference between iOS device and Mac),  only the issue occurs in iOS.

I have confirmed the timing of the issue when calling CreateDataSet() in ImageTracker script.

So app stops before new loaded dataset is avtivated.

 

To make sure of my environment, I had tried Xcode 4.5.1, 4.5.2, 4.6, and Unity 4.0.1, 4.1.

However, of course, these environment are not associated with my problem.

 

And I created new project, only attached my loading script with AR Camera.

I'm afraid that the result is wrong, the app also stops.

 

The same script functioned well in another project 3 months ago.

I cannot get it why this issue occurs.

 

Thanks, 

Eugene

 

xml & dat loaded successfully, but app stops

April 11, 2013 - 3:12am #2

I am not sure there is anything wrong.

The tracker will stop while a new dataset is being loaded, so this makes sense because unless the loading is completed Vuforia has no dataset to compare images against.

Is this the only issue you are seeing?

Does the app continue after the new loaded dataset is activated?

 

N

Log in or register to post comments