using UnityEngine; [ExecuteAlways] public sealed class OceanBendController : MonoBehaviour { public Transform anchor; [Min(1f)] public float radius = 123.578857f; public bool bendEnabled = true; static readonly int AnchorId = Shader.PropertyToID("_WorldBendAnchor"); static readonly int RadiusId = Shader.PropertyToID("_WorldBendRadius"); static readonly int EnabledId = Shader.PropertyToID("_WorldBendEnabled"); void OnEnable() => Apply(); void OnValidate() => Apply(); void LateUpdate() => Apply(); void Apply() { Vector3 p = anchor ? anchor.position : transform.position; Shader.SetGlobalVector(AnchorId, new Vector4(p.x,p.y,p.z,0)); Shader.SetGlobalFloat(RadiusId, Mathf.Max(radius,1f)); Shader.SetGlobalFloat(EnabledId,bendEnabled ? 1f : 0f); } void OnDisable() => Shader.SetGlobalFloat(EnabledId,0f); }