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.

45 lines
955 B

  1. using UnityEngine;
  2. [ExecuteInEditMode]
  3. public class WaterTile : MonoBehaviour
  4. {
  5. public PlanarReflection reflection;
  6. public WaterBase waterBase;
  7. public void Start ()
  8. {
  9. AcquireComponents();
  10. }
  11. private void AcquireComponents()
  12. {
  13. if (!reflection) {
  14. if (transform.parent)
  15. reflection = (PlanarReflection)transform.parent.GetComponent<PlanarReflection>();
  16. else
  17. reflection = (PlanarReflection)transform.GetComponent<PlanarReflection>();
  18. }
  19. if (!waterBase) {
  20. if (transform.parent)
  21. waterBase = (WaterBase)transform.parent.GetComponent<WaterBase>();
  22. else
  23. waterBase = (WaterBase)transform.GetComponent<WaterBase>();
  24. }
  25. }
  26. #if UNITY_EDITOR
  27. public void Update ()
  28. {
  29. AcquireComponents();
  30. }
  31. #endif
  32. public void OnWillRenderObject()
  33. {
  34. if (reflection)
  35. reflection.WaterTileBeingRendered(transform, Camera.current);
  36. if (waterBase)
  37. waterBase.WaterTileBeingRendered(transform, Camera.current);
  38. }
  39. }