Instant Image Targets¶
Create Image Targets instantly from an image asset stored locally or externally.
Create Image Targets in the Target Manager and download them as a Device Database or create them instantly from an image asset at runtime.
If you are looking for runtime loading Image Targets in Native, please refer to How to Create and Modify Targets in Native.
Image Target from an Image Asset¶
Use an image asset with sufficient details and import it into the Unity Editor to create an Image Target. Add the image asset to the ImageTargetBehaviour
component of the Image Target GameObject, and Vuforia will create the Image Target at runtime.
This method provides less information on the tracking quality and rating of the image asset than the Target Manager. You should, therefore, choose an image source that fulfills the best practices. CreateImageTarget()
has a limit of 2048 pixel size for the width and height.
Create instant Image Target
-
Open an empty Unity Project and add the Vuforia SDK.
-
Create an ARCamera GameObject and add a license from your Vuforia Developer account into the license key field in VuforiaConfiguration.
-
Load a detailed JPG or PNG image into the Assets folder.
-
Create a new Vuforia Engine ImageTarget GameObject.
-
In the Inspector of the ImageTarget GameObject, set the Type to From Image.
-
Drag the image file to the empty box labeled Image and give it a name.
-
You may need to set the image to "Read/Write Enabled" in the advanced import settings. The inspector will display a message if additional actions are required or if the image is at risk of being rescaled upon target creation.
NOTE: The expandable Advanced menu is for rescaling the ImageTarget GameObject.
-
-
Place your AR content as a child on the ImageTarget GameObject and use Vuforia's Play Mode by pressing Play or deploying the app to your device.
Create Instant Image Targets at Runtime from a file or Texture2D Objects¶
Alternatively, Instant Image Targets can be created at runtime in C#. Attach the following code to any GameObject in the scene. The script loads an image file from the StreamingAssets/Vuforia
folder and creates an Image Target at runtime. For more information on runtime loading, please see Create and Load Targets in Unity.
NOTE: A license key must be added to use instant Image Targets.
Image Target from an external texture2D source¶
The code example below downloads a texture image from a web URL and generates an Image Target. Attach the script to the ARCamera GameObject.
Learn More¶
Getting Started with Vuforia Engine in Unity