- Home /
Question by
ZedGames · May 20, 2018 at 10:46 PM ·
uiworldspacescreenspace
UI object marker showing up when object is outside view
So, I have a UI element scripted to hover over an object in world space, like so:
private void Update()
{
gameObject.transform.position = cam.WorldToScreenPoint(transformToFollow.position);
}
("cam" being the main camera and "transformToFollow" being the transform of the object I want the UI element to follow) However, when I run the game, the UI element is still visible even when the main camera is turned away from the object, as though it's hovering over the point directly opposite the target transform's position. How would I make it so that I can only see the UI element when the target object is within the view? I'm using this with an empty target object, so I don't think renderer.IsVisible will work.
Comment