I have a software that comunicates with a Unity3D module that I’m developing and passes an image and a list of Points. The points should be correctly placed on top of the image, but they are not. I’ve seen code samples that look into this problem, but none of the ones I tried works (the one I place here is actually one of them)
.
I place an image here as example of what I need to accomplish. In the image the “sphereCollider” that are seen (marked with a red circle) should be on top of the circles connected by the lines.
Does anyone knows how to solve this conversion problem?
My thanks in advanced
This is my code.
public void DrawOnScreen()
{
SphereCollider sphereCollider;
Vector3 v3Converted;
Vector3 v3ConvertedToWorldUnits;
Camera cam;
cam =GameObject.Find(“MainCamera”).camera;
foreach (Script_Ponto pt in LPt) {
sph=GameObject.CreatePrimitive(PrimitiveType.Sphere);
v3Converted=new Vector3(pt.PontoX,pt.PontoY,0);
v3ConvertedToWorldUnits=cam.WorldToScreenPoint(v3Converted);
sph.transform.position=v3ConvertedToWorldUnits;
sph.transform.localScale=new Vector3(4,4,4);
Debug.Log(“SPHERE x:” + sph.transform.position.x + " y:" + sph.transform.position.y + " z:" + sph.transform.position.z);
sphereCollider=sph.GetComponent();
sphereCollider.radius=SPHERESIZE;
gObj.Add(sph);
}
}