- Home /
Position prefab above imageview in specific pixel coordinates
Hi, i have this project where there is an imageview (map of a city) and i need to display above it some pins in specific locations using vuforia for unity.
I get latitude and longtitude of places and then i convert them, using the mercator projection, to pixels as described in Map Coordinates - Google. Then, i instatiate the prefab :
marker = (Transform) Instantiate(Resources.Load(("Marker"), typeof(Transform)), position, Quaternion.identity);
where position is a vector3 object with x value the latitude in pixels, y value the longtitude in pixels and z zero. When i build and run the project i can see the prefab created and added as a child to my imagetarget, but not in the correct position(actually it's positioned way above the imagetarget and the ARCamera). Is there a specific way to position the prefab correctly in the imageview for an AR application? I also tried to use the `worldToScreenPoint(new Vector3(x,y,z))` with no luck..
How can i position the prefab correctly, using vuforia for unity, in order to show up inside the imageview and in the right location.
Thank you in advance for you answers and your help will be appreciated
Answer by iwandi · Aug 31, 2012 at 04:24 PM
Add a offset like this.
(also i think you creating a GameObject not a Transfrom, so i changed the code)
Vector3 offset = new Vector3(0f,0f,-10f);
GameObject marker = (GameObject) Instantiate(Resources.Load(("Marker"), typeof(GameObject)), position + offset, Quaternion.identity) as GameObject;
Answer by JcDenton86 · Sep 03, 2012 at 09:07 AM
Thank you for your answer but this didn't solve my issue. Actually, I figured out that i have to convert lat/lon values in Unity's coordinate system values. Is there a way for that?
Your answer
Follow this Question
Related Questions
Convert to .tiff, with fbx export, removes the alpha channel? 1 Answer
Convert string to material 0 Answers
Convert Array 2 Answers
String to Var 2 Answers
Cannot convert object to gameObject 3 Answers