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

using UnityEngine;
[ExecuteInEditMode]
public class WaterTile : MonoBehaviour
{
public PlanarReflection reflection;
public WaterBase waterBase;
public void Start ()
{
AcquireComponents();
}
private void AcquireComponents()
{
if (!reflection) {
if (transform.parent)
reflection = (PlanarReflection)transform.parent.GetComponent<PlanarReflection>();
else
reflection = (PlanarReflection)transform.GetComponent<PlanarReflection>();
}
if (!waterBase) {
if (transform.parent)
waterBase = (WaterBase)transform.parent.GetComponent<WaterBase>();
else
waterBase = (WaterBase)transform.GetComponent<WaterBase>();
}
}
#if UNITY_EDITOR
public void Update ()
{
AcquireComponents();
}
#endif
public void OnWillRenderObject()
{
if (reflection)
reflection.WaterTileBeingRendered(transform, Camera.current);
if (waterBase)
waterBase.WaterTileBeingRendered(transform, Camera.current);
}
}