I’m trying to check if my game object is visible on the screen, but when I try and use renderer.isVisible it says it’s deprecated and I can’t find out another way to check if the object is on the Screen.
Yes, since Unity5 those properties are deprecated. You should use GetComponent() instead.
It actually said this exactly in the screenshot you posted ![]()
I’ve already tried that, and it isn’t working, can you post some code to help me out?
private Renderer m_renderer;
void Start()
{
m_renderer = GetComponent<Renderer>();
}
void Update()
{
if(m_renderer.isVisible)
{
//Do things
}
}
You need to post exactly what it’s saying when GetComponent() doesn’t work. As long as you actually have a renderer component on the object, it should work. We could post some code, but that’s literally the whole thing- there’s no build-up or preparation needed.
GetComponent(); is not equal to GetComponent<>(Renderer)
Possible versions are
GetComponent();
GetComponent(“Renderer”) as Renderer;
GetComponent(typeof(Renderer));

