I'm working on a tower defense game, where you can see a tower's radius as a guiTexture around the tower, while it's about to be placed on the map and while OnMouseOver the tower. This works perfectly in playmode with the offsets I've plotted in to place the radius correctly. However, once I build the project, the radius' position is completly off as if I didn't offset it both when the tower is about to be placed, and when OnMouseOver the tower.
Here is the code for the radius positioned on the tower:
`//Set position for radius and instantiate it. The variable "radius" holds the radius guiTexture.
position = new Vector3(transform.position.x + xOffSet, transform.position.y, transform.position.z + zOffSet);
worldPos = Camera.main.WorldToViewportPoint(position);
radiusClone = (GUITexture)Instantiate(radius, worldPos, transform.rotation);`
Here is the code for the radius positioned on the mouse before placing the tower on the map:
// place radius gui texture on mouse position by translating mouse position coordinates to normalized screen coordinates. The "TrooperRadius" guiTexture is found in the scene and moved to the mouse position.
trooperRadius = GameObject.Find("TrooperRadius");
trooperRadius.transform.position = new Vector3((Input.mousePosition.x + xOffSet) / Screen.width, (Input.mousePosition.y + zOffSet) / Screen.height, 0);
I also have an upgraded version of the radius for when the player upgrades the tower, which holds the same code as seen above just without the offsets, since the upgraded radius is a scaled version of the normal radius, and by coincidence the upgraded radius is positioned perfectly without offsets. However, there are no problems with the upgraded radius in the build, as it is positioned perfectly. There are only problems with the normal radius with offsets.
Your help is highly appreciated