public void lerpLight ()
{
if(_isCreating)
{
_camera.backgroundColor = Color.Lerp (_camera.backgroundColor, Color.black, 3*Time.deltaTime);
_directionalLight.intensity = Mathf.Lerp (_directionalLight.intensity, 0f, 3*Time.deltaTime);
_spotLightBL.GetComponent<Light>().intensity = Mathf.Lerp(_spotLightBL.GetComponent<Light>().intensity, _intensity, 1.5f*Time.deltaTime);
_backGroundSpotlight.GetComponent<Light>().intensity = Mathf.Lerp(_backGroundSpotlight.GetComponent<Light>().intensity, _bkIntensity, 3*Time.deltaTime);
//when finished
if (_camera.backgroundColor == Color.black)
_isCreating = false;
}
if(_isDestroying)
{
_camera.backgroundColor = Color.Lerp (_camera.backgroundColor, _initialBackground, 1.5f*Time.deltaTime);
_directionalLight.intensity = Mathf.Lerp (_directionalLight.intensity, _initialIntensity, 1.5f*Time.deltaTime);
_spotLightBL.GetComponent<Light>().intensity = Mathf.Lerp(_spotLightBL.GetComponent<Light>().intensity, 0f, 3f*Time.deltaTime);
//when finished
if (_camera.backgroundColor == _initialBackground)
{
Destroy(gameObject.transform.FindChild("spotLightBL").gameObject);
_isDestroying = false;
}
}
}