Log in or register to post comments

Split Android Binary doesn't work (already tried stickied topic)

September 6, 2018 - 10:19am #1

I can't get Split Application Binary to work with vuphoria even when using the code in the stickied topic on this subject.

(I realised I spelled vuforia wrong in some of my method and field names - but I have it correct where it needs to be correct)

I am doing this in a 'menu' screen that is used where vuforia isn't used.  The 'UIController.VuphoriaDataLoaded' prevents the user from pushing the button that changes over to the camera scene until all the data is loaded - but it happens nearly instantly so I probably didn't need to do that.  I have delayed initialization turned on.  (I have also tried it with delayed initialization off and not doing the initVuforia here)

The array of strings 'keys' is a list of all the dataset keys that need to be loaded.  All of the save debugs return values that say things are saved properly.

using System.IO;<br>
	using System.Collections;<br>
	using UnityEngine;<br>
	using UnityEngine.SceneManagement;<br>
	using Vuforia;</p>
<p><br>
	public class ObbExtractor : MonoBehaviour {<br>
	    public static void initVuphoria() {<br>
	        VuforiaRuntime.Instance.InitVuforia();<br>
	        UIController.VuphoriaDataLoaded = true;<br>
	    }</p>
<p>    int startCount = 0;<br>
	    int doneCount = 0;</p>
<p>    public string[] keys = new string[] { };</p>
<p>    void Start() {<br>
	#if UNITY_ANDROID<br>
	        UIController.VuphoriaDataLoaded = false;<br>
	        foreach (string s in keys) {<br>
	            StartCoroutine(ExtractObbDatasets(s));<br>
	        }<br>
	#else<br>
	        initVuphoria();<br>
	#endif<br>
	    }</p>
<p>    private IEnumerator ExtractObbDatasets(string file) {<br>
	        startCount++;<br>
	        string[] filesInOBB = { file+".dat", file+".xml" };<br>
	        foreach (var filename in filesInOBB) {<br>
	            string uri = Application.streamingAssetsPath + "/Vuforia/" + filename;</p>
<p>            string outputFilePath = Application.persistentDataPath + "/Vuforia/" + filename;<br>
	            if (!Directory.Exists(Path.GetDirectoryName(outputFilePath)))<br>
	                Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath));</p>
<p>            var www = new WWW(uri);<br>
	            yield return www;</p>
<p>            Save(www, outputFilePath);<br>
	            yield return new WaitForEndOfFrame();<br>
	        }<br>
	        // When done extracting the datasets, Start Vuforia AR scene<br>
	        if (doneCount >= startCount)<br>
	            initVuphoria();<br>
	       <br>
	       <br>
	    }</p>
<p> </p>
<p>    private void Save(WWW www, string outputPath) {<br>
	        File.WriteAllBytes(outputPath, www.bytes );</p>
<p>        // Verify that the File has been actually stored<br>
	        if (File.Exists(outputPath)) {<br>
	            ShivaDebug.Log("File successfully saved at: " + outputPath);<br>
	            doneCount++;<br>
	        } else {<br>
	            ShivaDebug.Log("Failure!! - File does not exist at: " + outputPath);<br>
	        }<br>
	    }<br>
	}
Log in or register to post comments