using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; [RequireComponent(typeof(MeshFilter))] [RequireComponent(typeof(MeshRenderer))] public class WaterManager : MonoBehaviour { private MeshFilter meshFilter; private void Awake() { meshFilter = GetComponent(); } private void Update() { Vector3[] vertices = meshFilter.mesh.vertices; for (int i = 0; i < vertices.Length; i++) { vertices[i].y = WaveManager.Instance.GetWaveHeight(transform.position.x + vertices[i].x); } meshFilter.mesh.vertices = vertices; meshFilter.mesh.RecalculateNormals(); } }