2015-05-08 08:09:28 +00:00
|
|
|
using System;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace UnityStandardAssets.Water
|
|
|
|
{
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
public class WaterBasic : MonoBehaviour
|
|
|
|
{
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
Renderer r = GetComponent<Renderer>();
|
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Material mat = r.sharedMaterial;
|
|
|
|
if (!mat)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector4 waveSpeed = mat.GetVector("WaveSpeed");
|
|
|
|
float waveScale = mat.GetFloat("_WaveScale");
|
|
|
|
float t = Time.time / 20.0f;
|
|
|
|
|
|
|
|
Vector4 offset4 = waveSpeed * (t * waveScale);
|
|
|
|
Vector4 offsetClamped = new Vector4(Mathf.Repeat(offset4.x, 1.0f), Mathf.Repeat(offset4.y, 1.0f),
|
|
|
|
Mathf.Repeat(offset4.z, 1.0f), Mathf.Repeat(offset4.w, 1.0f));
|
|
|
|
mat.SetVector("_WaveOffset", offsetClamped);
|
|
|
|
}
|
|
|
|
}
|
2015-03-12 08:44:44 +00:00
|
|
|
}
|