1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Water
5 {
6     
[ExecuteInEditMode]
7     
public class WaterTile : MonoBehaviour
8     {
9         
public PlanarReflection reflection;
10         
public WaterBase waterBase;
11
12
13         
public void Start()
14         {
15             AcquireComponents();
16         }
17
18
19         
void AcquireComponents()
20         {
21             
if (!reflection)
22             {
23                 
if (transform.parent)
24                 {
25                     reflection = transform.parent.GetComponent<PlanarReflection>();
26                 }
27                 
else
28                 {
29                     reflection = transform.GetComponent<PlanarReflection>();
30                 }
31             }
32
33             
if (!waterBase)
34             {
35                 
if (transform.parent)
36                 {
37                     waterBase = transform.parent.GetComponent<WaterBase>();
38                 }
39                 
else
40                 {
41                     waterBase = transform.GetComponent<WaterBase>();
42                 }
43             }
44         }
45
46
47 #
if UNITY_EDITOR
48         
public void Update()
49         {
50             AcquireComponents();
51         }
52 #endif
53
54
55         
public void OnWillRenderObject()
56         {
57             
if (reflection)
58             {
59                 reflection.WaterTileBeingRendered(transform, Camera.current);
60             }
61             
if (waterBase)
62             {
63                 waterBase.WaterTileBeingRendered(transform, Camera.current);
64             }
65         }
66     }
67 }