- Home /
Set renderable objects on camera without Layers
I need a camera to render only specific objects/renderers when I call the Camera.Render() function. Is it possible to do that without using render layers?
The best solution I can come up with is to move the object 100000 units away (or something) and then render it with a smaller far clip, but that's awfully hacky.
So, what's wrong with using render layers? It's like asking "I want to nail together this box, but I don't want to use a hammer"
Because sometimes you need a screw ;)
If I use render layers I will either have to have a layer that's always reserved for an action that will not run that frequently or assign a layer to each object and camera pair, which is more than a little silly.
I will mostly render a single object to a camera and reserving a render layer for that seems a bit excessive.
I can work with the reserved layer thing, however, ideally I'd like to say something like: Camera.Render(Renderer[]); which doesn't exist obviously but it would be nice.
Why, exactly, are you doing this? What's the desired outcome?
I'm writing a system that will automatically convert any renderer into impostors. So I need to be able to render an object on it's own without outside interference. I've got most of it working, right now the biggest headache is the fact that multiple objects can be rendered when I just need to the one.
I have a similar problem with multiple objects needing to be rendered on regular intervals on their own for later use. With OpenGL I put together a little routine I would attach to all the object that needed that, with Unity it seems impossible.
Answer by msknapp · Jan 05, 2012 at 12:28 AM
For the objects you don't want to render, add code to this effect:
GameObject myGameObject = ...
myGameObject.renderer.enabled=false;
I'm not keen on this solution, as I may need to turn renderers off for hundreds if not thousands of objects.
This is a terrible idea in a scene which contains hundreds of little objects...
Answer by WheresMommy · Dec 13, 2019 at 12:23 PM
I would set the layer on runtime to render for the objects you need and then revert.