Log in or register to post comments

Activate ImageTarget in runtime

August 15, 2014 - 9:35am #1

hello,

I have a problem,

I try to create a imageTarget in a scene but i want to start the scene with this target deactivated or in a prefab to instatiate it later, 

but when I activate the target in runtime this is not working not calling to the OnTrackableFound().

the only way I found was activate the arcamera at the same time but this is no what i want each time a activate o instatiate a target.

how can i make this work? Any idea?

 

Thank you

Activate ImageTarget in runtime

August 26, 2014 - 10:22am #5

This is my method to Create and Load A Dataset I think is very similar to one that i found in article:

 

        /// <summary>
	/// Load and activate a data set at the given name.
	/// </summary>
	/// <returns><c>true</c>, if data set was loaded, <c>false</c> otherwise.</returns>
	/// <param name="dataSetName">Data set name.</param>
	public bool LoadDataSet (string dataSetPath)
	{
		// Check if the data set file exists at the given path.
		if (!DataSet.Exists (dataSetPath)) {
			Debug.LogError ("Data set " + dataSetPath + " does not exist.");
			return false;
		}
		
		// Request an ImageTracker instance from the TrackerManager.
		ImageTracker imageTracker =
			(ImageTracker)TrackerManager.Instance.GetTracker<ImageTracker> ();

		
		
		// Create a new empty data set.
		DataSet dataSet = imageTracker.CreateDataSet ();
		
		// Load the data set from the given path.
		if (!dataSet.Load (dataSetPath)) {
			Debug.LogError ("Failed to load data set " + dataSetPath + ".");
			return false;
		}
		
		// (Optional) Activate the data set.
		imageTracker.ActivateDataSet (dataSet);
		
		return true;
	} 

I call this method inside the OnEnable in one script inside the prefab that contain the targets I want to charge. Then the targets and the dataSet are intitialized at the same time. 

 

Activate ImageTarget in runtime

August 21, 2014 - 12:23am #4

I have the similar task, can you please tell your way to do this?

Activate ImageTarget in runtime

August 20, 2014 - 6:59am #3

 

I am sorry but that is not what I want, I need to put the Image target with the options alredy set inside the prefab to instantiate all together.

Any way I found the way creating, loading and activating the datasets at the same time that I instantiate the prefab with the image targets.

Maybe is helpful for other person.

Activate ImageTarget in runtime

August 19, 2014 - 7:14pm #2

You will need to place the ImageTarget prefabs in the Unity environment and manually set the correct ImageTarget from the Dataset, but you can programmatically add the 3D augmentation objects dynamically. Here's an FAQ that explains how:

https://developer.vuforia.com/forum/faq/unity-how-can-i-dynamically-attach-my-3d-model-image-target
 

Log in or register to post comments