Log in or register to post comments

Sprite over an ImageTarget (Unity)

March 14, 2016 - 12:51pm #1

Hi,

Im trying to display an Image (which i download from the web and then transform into a texture) as a sprite over an ImageTarget in Unity. Im having trouble covering the area of the ImageTarget completely, so that this is not visible anymore. How do achieve this? Thanks for your help.

Sprite over an ImageTarget (Unity)

May 10, 2016 - 11:45pm #2

First make sure that your PNG image has the same aspect ratio (width / height ratio) as your Image Target; you can compute the aspect ratio of the Image Target by looking at the width and height parameters in the Dataset XML.  

If the aspect ratio is different, you may want to either crop the image or add some borders (or else simply rescale it in a non-uniform way) so that it gets the proper aspect ratio.

Then, make sure the image is added as a child of the Image Target in your Unity scene and scale it so that it covers the Image Target surface completely. 

If you ant to do it programmatically, via a script at runtime, you'll need to get the Size (GetSize() method) of your ImageTarget and apply that size to the scale of your image.

If the image does not completely fill the Image Target (e.g. by a few pixels) when seen through the camera, this might be a little pixel-level inacuracy, which you could fix by slightly increasing the scale of the image by a very small amount (e.g. by +1% or so).

 

Log in or register to post comments