还原水插件

This commit is contained in:
2026-03-05 00:14:42 +08:00
parent 0de35591e7
commit e82f2ea6b7
270 changed files with 2773 additions and 12445 deletions

View File

@@ -1,173 +0,0 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
namespace WaveHarmonic.Crest.Examples
{
[AddComponentMenu(Constants.k_MenuPrefixSample + "Waterfall (Sample)")]
[ExecuteAlways]
sealed class Waterfall : MonoBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
public Transform _Crest;
public float _CrestRadius = 1f;
public Transform _Face;
public float _FaceAngle = 5f;
public Transform _Waves;
[Tooltip("The bottom of the waterfall. If unset, it will use sea level.")]
public Transform _PlungePool;
public Transform _Foam;
public float _FoamOffset;
public float _FoamPadding;
public Transform _Flow;
public float _FlowPadding = 10f;
float HeightFromPlungePool => transform.position.y - (_PlungePool != null
? _PlungePool.position.y
: WaterRenderer.Instance != null
? WaterRenderer.Instance.SeaLevel
: 0f);
void OnEnable()
{
Update();
}
void Update()
{
UpdateFace();
UpdateCrest();
UpdateWaves();
UpdateFoam();
UpdateFlow();
}
void UpdateCrest()
{
if (_Crest == null)
{
return;
}
var crest = _Crest;
var position = crest.localPosition;
position.y = -_CrestRadius;
crest.localPosition = position;
var scale = crest.localScale;
scale.x = _CrestRadius * 2f;
scale.z = _CrestRadius * 2f;
crest.localScale = scale;
}
void UpdateFace()
{
if (_Face == null)
{
return;
}
var face = _Face;
var angle = _FaceAngle * Mathf.Deg2Rad;
var ratio = 1f / Mathf.Cos(angle);
var height = HeightFromPlungePool - _CrestRadius;
var center = height * 0.5f;
var rotation = face.localRotation.eulerAngles;
rotation.x = 90f - _FaceAngle;
face.localRotation = Quaternion.Euler(rotation);
// Plane is 10m.
var scale = face.localScale;
scale.z = height * 0.1f * ratio;
face.localScale = scale;
var position = face.localPosition;
position.y = -center;
position.z = center * ratio * Mathf.Sin(angle);
position.y += -_CrestRadius;
position.z += _CrestRadius;
face.localPosition = position;
}
void UpdateWaves()
{
if (_Waves == null)
{
return;
}
var waves = _Waves;
var feather = 0f;
if (_Waves.TryGetComponent<Renderer>(out var renderer) && renderer.sharedMaterial != null && renderer.sharedMaterial.IsKeywordEnabled("d_Feather"))
{
feather = renderer.sharedMaterial.GetFloat(Shader.PropertyToID("_Crest_FeatherWidth"));
}
var position = waves.localPosition;
var scale = waves.localScale.x;
position.z = scale * 0.5f + (_Face.localPosition.z * 2f - _CrestRadius) - feather * scale;
position.y = -HeightFromPlungePool;
waves.localPosition = position;
}
void UpdateFoam()
{
if (_Foam == null)
{
return;
}
var foam = _Foam;
var size = _Face.localPosition.z * 2f - _CrestRadius;
var scale = foam.localScale;
scale.y = size + _FoamPadding;
foam.localScale = scale;
var position = _Foam.localPosition;
position.z = size * 0.5f + _FoamOffset;
_Foam.localPosition = position;
}
void UpdateFlow()
{
if (_Flow == null)
{
return;
}
var flow = _Flow;
var size = _Face.localPosition.z * 2f - _CrestRadius;
var scale = flow.localScale;
scale.y = size + _FlowPadding;
flow.localScale = scale;
var position = _Flow.localPosition;
position.z = size * 0.5f;
_Flow.localPosition = position;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d6cefaddfdcb9420abe40ac27e03cd4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,26 +0,0 @@
{
"name": "WaveHarmonic.Crest.Samples.Waterfall",
"rootNamespace": "",
"references": [
"GUID:7c347618730f5467f86a58f333ce21df",
"GUID:056ff2a5b2f124d468c6655552acdca5"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"UNITY_2022_3_OR_NEWER",
"d_Crest"
],
"versionDefines": [
{
"name": "com.waveharmonic.crest",
"expression": "",
"define": "d_Crest"
}
],
"noEngineReferences": false
}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 054255244fbfd4fa8b9b4d829c6bc703
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: