using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class SceneLight : MonoBehaviour {
|
|
|
|
void Awake()
|
|
{
|
|
UpdateLight();
|
|
}
|
|
|
|
|
|
// void Update()
|
|
// {
|
|
//UpdateLight();
|
|
// }
|
|
|
|
void UpdateLight()
|
|
{
|
|
Light lit = GetComponent<Light>();
|
|
if (lit != null && lit.type == LightType.Directional)
|
|
{
|
|
Vector4 col = new Vector4(lit.color.r, lit.color.g, lit.color.b, lit.color.a);
|
|
col *= lit.intensity;
|
|
Shader.SetGlobalVector("_GlobalLightColor", col);
|
|
Vector3 dir = -lit.transform.forward;
|
|
Shader.SetGlobalVector("_GlobalLightDir", new Vector4(dir.x, dir.y, dir.z, 0f));
|
|
}
|
|
}
|
|
|
|
|
|
}
|