//Copyright protected under Unity Asset Store EULA
usingSystem.Collections.Generic;
usingUnityEngine;
namespaceStylizedWater2
{
[ExecuteInEditMode]
[AddComponentMenu("Stylized Water 2/Align Transform To Waves")]
publicclassAlignToWaves:MonoBehaviour
{
[Tooltip("This reference is required to grab the wave distance and height values")]
publicWaterObjectwaterObject;
[Tooltip("Automatically find the Water Object below of above the Transform's position. This is slower than assigning a specific Water Object directly.")]
publicboolautoFind;
[Tooltip("Only enable if the material's wave parameters are being changed in realtime, this has some performance overhead.\n\nIn edit-mode, the wave parameters are always fetched, so changes are directly visible")]
publicbooldynamicMaterial;
publicenumWaterLevelSource
{
FixedValue,
WaterObject
}
[Tooltip("Configure what should be used to set the base water level. Relative wave height is added to this value")]
[Tooltip("You can assign a child mesh object here. When assigned, the sample points will rotate/scale with the transform, instead of transform the component is attached to.")]
publicTransformchildTransform;
publicfloatheightOffset;
[Min(0)]
[Tooltip("Controls how strongly the transform should rotate to align with the wave curvature")]
publicfloatrollAmount=0.1f;
publicList<Vector3>samples=newList<Vector3>();
privateVector3normal;
privatefloatheight;
privatefloatm_waterLevel=0f;
/// <summary>
/// Global toggle to disable the animations. This is used to temporarily disable all instances when editing a prefab, or sample positions in the editor