升级水插件

This commit is contained in:
2026-01-08 22:30:55 +08:00
parent febff82d24
commit ca68084264
415 changed files with 18138 additions and 7134 deletions

View File

@@ -1,4 +1,4 @@
// Crest Water System
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#if UNITY_EDITOR
@@ -16,9 +16,11 @@ namespace WaveHarmonic.Crest
{
internal const string k_ProxyShader = "Hidden/Crest/Editor/WaterProxy";
internal GameObject _ProxyPlane;
internal bool IsProxyPlaneRendering => !Application.isPlaying && _ShowWaterProxyPlane;
private protected override bool CanRunInEditMode => !_ShowWaterProxyPlane;
internal static float LastUpdateEditorTime { get; set; } = -1f;
internal static float EditorTime { get; set; }
internal static float EditorDeltaTime { get; set; }
static int s_EditorFrames = 0;
// Useful for rate limiting processes called outside of RunUpdate like camera events.
@@ -34,6 +36,9 @@ namespace WaveHarmonic.Crest
{
_Underwater._Material = AssetDatabase.LoadAssetAtPath<Material>("Packages/com.waveharmonic.crest/Runtime/Materials/Water Volume.mat");
_Surface.Reset();
Meniscus.Reset();
base.Reset();
}
@@ -66,12 +71,13 @@ namespace WaveHarmonic.Crest
if (!Application.isPlaying)
{
if (EditorApplication.timeSinceStartup - LastUpdateEditorTime > 1f / Mathf.Clamp(Instance._EditModeFrameRate, 0.01f, 60f))
if ((Time.time - EditorTime) >= (1f / Mathf.Clamp(Instance._EditModeFrameRate, 0.01f, 120f)))
{
s_EditorFrames++;
s_EditorFramesSinceUpdate = 0;
LastUpdateEditorTime = (float)EditorApplication.timeSinceStartup;
EditorDeltaTime = Time.time - EditorTime;
EditorTime = Time.time;
Instance.RunUpdate();
}
@@ -90,6 +96,28 @@ namespace WaveHarmonic.Crest
{
AfterScriptReload();
}
[@OnChange]
void OnChange(string path, object previous)
{
switch (path)
{
case nameof(_ExtentsSizeMultiplier):
case nameof(_GeometryDownSampleFactor):
Surface._Rebuild = true;
break;
case nameof(_ShowWaterProxyPlane):
SetShowProxyPlane((bool)previous, _ShowWaterProxyPlane);
break;
}
}
void SetShowProxyPlane(bool previous, bool current)
{
if (previous == current) return;
if (!isActiveAndEnabled || Application.isPlaying) return;
if (!(runInEditMode = !_ShowWaterProxyPlane)) OnDisable();
}
}
partial class WaterRenderer