Log in or register to post comments

Custom Prefab with 3D Obj and Vuforia Prefab for AssetBundles

October 30, 2013 - 8:23am #1

Hi Guys!

I am having a hard time implementing an android application in Unity 4.2.1f4 and the Vuforia plugin. I am tried to load FrameMarkers with the assigned 3D Objects from an assetbundle. I have successfully managed to load the 3D objects and assign them to Markers which are already in the scene. However, the goal is not to have any of the FrameMarkers in the scene, but to load them automatically with bundle.LoadAll() and afterwards instantiating them, because I dont want to know which Markers will be used.

The Problem: I load the objects and markers, I instantiate them, the markers are being recognized and tracked by the plugin, but the Objects are not being rendered.

Observation 1: I made a small experiment by loading two different types of prefabs. The only difference between the once that are renderer and the once that are not rendered, are the location of the prefabs of the FrameMarkers. While the working ones are in Qualcomm Augmented Reality/Prefabs, the other ones (which are actually exact copies) are in an other folder. Does this mean that the prefab of the FrameMarkers have to be in the Qualcomm folder for the objects to be correctly displayed?

Observation 2: I know assetBundles doesnt contain scripts. Thats why ALL SCRIPTS are in my Assets. this should no be the problem. 

I hope you can help me out



Custom Prefab with 3D Obj and Vuforia Prefab for AssetBundles

November 4, 2013 - 2:12am #4

If someone is interested in my solution:

At the end what I did was to save the Objects WITHOUT the FrameMarker relation in the AssetBundle. When loading the AssetBundle I control if there are Object with a specific Prefix (FMObj* in my case) and creates the corresponding FrameMarker with the code of the following post: 


Custom Prefab with 3D Obj and Vuforia Prefab for AssetBundles

November 3, 2013 - 11:49pm #3

At the moment I work only with one FrameMarker to figure out the tracking problems.

Side note: On the custom prefab, the FrameMarke has MarkerID = -1, but when I drag it to the scene, it gets the MarkerID 0. Bug?

This morning I just found something out: When draging the prefab to the scene, all the scripts are attached, but at runtime it doesnt behave like it would have the scripts DefaultTrackableEventHandler, MarkerBehavior and TurnOffBehaviour. After re-attaching the scripts to the GameObject in the scene, building and running it, everything works. Saving that object to a prefab and creating a second object from that prefab generates the same wrong behaviour.

Am I doing something wrong when creating the prefabs or is this a Bug?


EDIT: I realize that instead off drag-and-drop the changed GameObjects(Id and scripts) to the new prefab, if I "apply" the changes on the Object, they will be saved in the prefab correctly.It seams that saving those prefabs in an AssetBundle and loading them is the problem now... 

EDIT2: I will try to pre-compile the Scripts and load them as in : http://docs.unity3d.com/Documentation/Manual/scriptsinassetbundles.html to see if that solves the problem...

EDIT3: It didnt work, because the Scripts needed to co-compile all the dependencies (of course) and that created a hugh file, which I didnt want to include in all AssetBundles... I need help :(((((

Custom Prefab with 3D Obj and Vuforia Prefab for AssetBundles

October 31, 2013 - 1:19am #2

Have you checked the MarkerID of the markers that come from your Asset Bundles ? 

you can do it with:

int id = marker.MarkerID;

It might be that they are all 0...

Log in or register to post comments