源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

31 行
605 B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class SceneLight : MonoBehaviour {
  4. void Awake()
  5. {
  6. UpdateLight();
  7. }
  8. // void Update()
  9. // {
  10. //UpdateLight();
  11. // }
  12. void UpdateLight()
  13. {
  14. Light lit = GetComponent<Light>();
  15. if (lit != null && lit.type == LightType.Directional)
  16. {
  17. Vector4 col = new Vector4(lit.color.r, lit.color.g, lit.color.b, lit.color.a);
  18. col *= lit.intensity;
  19. Shader.SetGlobalVector("_GlobalLightColor", col);
  20. Vector3 dir = -lit.transform.forward;
  21. Shader.SetGlobalVector("_GlobalLightDir", new Vector4(dir.x, dir.y, dir.z, 0f));
  22. }
  23. }
  24. }