Making object invisible

Is there a way of making an object invisible without disabling mesh renderer?

You could try playing around with rendering layers to make the camera ignore a certain set of GameObjects.

I don’t know your situation so it’s hard to answer, but I had the same question due to a script that uses OnWillRenderObject. I need the object to always render (for each camera) but not to actually be visible. My current best solution is to use a very large cube with no back faces visible. Any better ideas welcomed though.

Other ideas you could use depending on your situation - scale the object down until it’s too small to see, or move it behind the camera?

I have a tank that dies, and I want it to become invisible for a bit while it explodes, then respawns. Scripts need the mesh renderer so I can’t remove it.

public GameObject objectToRender;

private void OnPreCullCallback(Camera camera)
{
    objectToRender.transform.position = camera.transform.position;
}

private void OnEnable()
{
    Camera.onPreCull += OnPreCullCallback;
}

private void OnDisable()
{
    Camera.onPreCull -= OnPreCullCallback;
}

Even works fine for the editor camera and camera previews. Here I just put the object at the same location as the camera, but you could also put it in front of it.

Edit: Also, instead of using an invisible object that is always in view to call OnWillRenderObject, you can also just add a CallBack to onPreRender.