- Home /
Dissable lights per camera?
I did have this working before i updated to the latest unity version with this script:
public List<Light> Lights;
void OnPreRender(){
foreach (Light light in Lights){
light.enabled = false;
}
}
void OnPostRender(){
foreach (Light light in Lights){
light.enabled = true;
}
}
Is there any other way to disable lights per camera when both cameras are rendering at the same time.
Answer by Kennyist · Nov 23, 2013 at 02:18 AM
Nevermind, This has been fixed using "OnPreCull()" instead of OnPreRender.
Answer by Ryan-Gatts · Nov 26, 2013 at 09:19 AM
ooh, would anyone like to explain this to me? I currently have a problem where I'm having flares render twice in a scene and I don't know how to disable individual lights per camera (I need some flares to render on one camera and a different set to render on the second).
Just put this script on the camera you want to hide lights from, And drop each light into the list:
public List<Light> Lights;
void OnPreCull(){
foreach (Light light in Lights){
light.enabled = false;
}
}
void OnPostRender(){
foreach (Light light in Lights){
light.enabled = true;
}
}
But unfortunately, I've never had luck with getting flares to not render on a certain camera, They just get stuck in half fade.
Your answer
Follow this Question
Related Questions
Rendertype for Unity's non-legacy Image UI 0 Answers
Camera stops rendering objects whenever this smooth follow 2D Script is applied 2 Answers
Multiple Cars not working 1 Answer
Two Cameras, Want One to Send Data of Both 0 Answers
How to toggle Post Processing on new Camera component in C#? 1 Answer