Extracting Dataset (AR) from OBB (Expansion Files)

Bear with me on this one, its mainly a question about correct coding.

I have an Augmented Reality project that I’m using OBB Expansion Files with. I’ve got it all working great but the ARCamera doesn’t augment anything. I know this requires some coding in order to extract the .XML and .DAT files specified here:

https://developer.vuforia.com/forum/faq/unity-how-can-i-handle-large-android-apps
https://developer.vuforia.com/forum/faq/unity-loading-dataset-sd-card
https://developer.vuforia.com/forum/android/android-split-issue-unity3d

Based on these 3 links I’ve come up with this:

First I created a scene with a Main Camera and Empty GameObject in it. On the GameObject I put the following script:

using UnityEngine;
using System.Collections;
using System.IO;

public class ObbExtractor : MonoBehaviour
{
	private string urlOfDatasetInObb, filePath, directoryPath;
	private IEnumerator loadARComponentsForAPKSplit()
	{
		//if UNITY_ANDROID
		urlOfDatasetInObb = System.String.Empty;
		filePath = directoryPath = System.String.Empty;
		directoryPath = (Application.persistentDataPath + "/QCAR");
		Directory.CreateDirectory (directoryPath);
		yield return null;
		
		urlOfDatasetInObb = (Application.streamingAssetsPath + "/QCAR/TrackerName.xml"); 
		var www = new WWW(urlOfDatasetInObb); 
		yield return www;
		filePath = Path.Combine(directoryPath, "TrackerName.xml");
		File.WriteAllBytes(filePath, www.bytes);
		yield return null;
		
		urlOfDatasetInObb = filePath = System.String.Empty;
		www = null;
		
		urlOfDatasetInObb = (Application.streamingAssetsPath + "/QCAR/TrackerName.dat");
		www = new WWW(urlOfDatasetInObb); 
		yield return www;
		filePath = Path.Combine(directoryPath, "TrackerName.dat");
		File.WriteAllBytes(filePath, www.bytes );

		Application.LoadLevel("ARScene");
	}   		
	// Can load the level now!
	//endif
	}

Then I created a basic AR scene; tracker and basic model. On the ARCamera, I put the following script:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Extract : MonoBehaviour {
	
	private bool mDataSetsLoaded = false;
	private string[] mDataSetNames = new string[] {"TrackerName.xml", "TrackerName.dat"}; //replace with your dataset name
	// Update is called once per frame
	void Update () 
	{
		ImageTracker itracker = TrackerManager.Instance.GetTracker<ImageTracker>(); 
		if (itracker == null) return;
		if (!mDataSetsLoaded) {
			string dataSetRootDir = Application.persistentDataPath + "/QCAR/";
			foreach(var datasetName in mDataSetNames) {
				DataSet dataSet = itracker.CreateDataSet();
				if (dataSet.Load (dataSetRootDir + datasetName, QCARUnity.StorageType.STORAGE_ABSOLUTE))
					itracker.ActivateDataSet(dataSet);
			}
			mDataSetsLoaded = true;
		}
	}
}

I then made sure the Dataset is selected and activated, the Write Access is set to External(SDCard) and Split Binary is checked. Whether I test it in Play Mode, or Build and Run it onto my Samsung Galaxy Tab, nothing happens.

Does anyone have a clue what I’m missing?

Thanks in advance

1 Answer

1

Thanks
Now, how to load the movie on the Android SD Card?

Sorry I’m Not Full English!