You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
570 B

  1. using UnityEngine;
  2. [RequireComponent(typeof(WaterBase))]
  3. [ExecuteInEditMode]
  4. public class SpecularLighting : MonoBehaviour
  5. {
  6. public Transform specularLight;
  7. private WaterBase waterBase = null;
  8. public void Start ()
  9. {
  10. waterBase = (WaterBase)gameObject.GetComponent(typeof(WaterBase));
  11. }
  12. public void Update ()
  13. {
  14. if (!waterBase)
  15. waterBase = (WaterBase)gameObject.GetComponent(typeof(WaterBase));
  16. if (specularLight && waterBase.sharedMaterial)
  17. waterBase.sharedMaterial.SetVector("_WorldLightDir", specularLight.transform.forward);
  18. }
  19. }