• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hollym16 · Sep 19, 2014 at 10:43 AM · androidgameobjectaugmented-realityobb

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by Hamed_razor · Apr 26, 2015 at 09:25 PM

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

Sorry I'm Not Full English!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

You may not have purchased this app (OBB Expansion Files) 1 Answer

Scripting error message 1 Answer

print out the value (string) of the URL passed to the WWW in the google console 0 Answers

OBB Expansion Files 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges