- Home /
LIGHT SHOW ONLY IN SPECIFIC CAMERA?
I have this scene:

Where my surveillance camera image is rendered in a plane on the wall.
I want to turn all lights off and show light only in the surveillance camera, like this:

How can i achieve this?
Answer by TrickyHandz · Aug 28, 2013 at 06:48 PM
You will have to make use of the OnPreRender() and OnPostRender() functions to pull something like this off, at least in my experience.
Here is a C# Script that will do it for you:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class LightingChange : MonoBehaviour
{
public List<Light> Lights;
void OnPreRender()
{
foreach (Light light in Lights)
{
light.enabled = false;
}
}
void OnPostRender()
{
foreach (Light light in Lights)
{
light.enabled = true;
}
}
}
Attach this script to the camera you want to show the lights. Add every light you want to be affected to the List "Lights" in the inspector and they should be turned off in all other cameras. Hope that helps.
Thanks @TrickyHandz, with your script i could create a new one to achieve what i want!
Your answer
Follow this Question
Related Questions
Camera Icon 1 Answer
How to make camera position relative to a specific target. 1 Answer
Why SSAO only works with clear flags "Don't clear"? 0 Answers
v2019.4 Gizmos NOT VISIBLE 0 Answers
The "top" camera is removing image effects from the bottom. 2 Answers