summaryrefslogtreecommitdiff
path: root/SyncCausticsWaterLevel.cs
blob: 7bfadff93911a80edbe76e71f3684dc298ede00e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using UnityEngine;

[AddComponentMenu("Relief Terrain/Helpers/Sync Caustics Water Level")]
[ExecuteInEditMode]
public class SyncCausticsWaterLevel : MonoBehaviour
{
	public GameObject refGameObject;

	public float yOffset;

	private void Update()
	{
		if ((bool)refGameObject && (bool)refGameObject.GetComponent<Renderer>())
		{
			refGameObject.GetComponent<Renderer>().sharedMaterial.SetFloat("TERRAIN_CausticsWaterLevel", base.transform.position.y + yOffset);
		}
		else
		{
			Shader.SetGlobalFloat("TERRAIN_CausticsWaterLevel", base.transform.position.y + yOffset);
		}
	}
}