之前学过一个是做流水效果的
但是自我感觉效果不太好,波动太规律了,而且能看到上面的面像是由多个面组合成的,感觉有点假,不过功能是实现了。
using UnityEngine;
using System.Collections;
public class CreateWater : MonoBehaviour {
Mesh mesh;
public int tier = 10;//长度分段
public int length = 10;//长
public int width = 3;//宽
public int hight = 10;//高
private Vector3[] vs;//顶点坐标
private int[] ts;//顶点序列
private Vector2[] newUVs;//UV贴图
private Vector3[] newNormals;//法线
void Update()
{
int temp = ((tier + 1) * 8 + 4) * 3;//确定顶点数量
vs = new Vector3[temp];
ts = new int[temp];
newUVs = new Vector2[temp];
newNormals = new Vector3[temp];
float dis = 2 * Mathf.PI / tier;//两段只差的横坐标
int count = 0;
for (int i = 0; i < tier; i++)
{
float pos1 = i * length / tier - length / 2;
float pos2 = (i + 1) * length / tier - length / 2;
//顶面顶点坐标
vs[count] = new Vector3(pos1, Mathf.Sin(Time.time + i * dis), width);
vs[count + 1] = new Vector3(pos2, Mathf.Sin(Time.time + (i + 1) * di