还原水插件

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

@@ -17,7 +17,19 @@ namespace WaveHarmonic.Crest
internal const string k_ProxyShader = "Hidden/Crest/Editor/WaterProxy";
internal GameObject _ProxyPlane;
private protected override bool CanRunInEditMode => !_ShowWaterProxyPlane;
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.
static int s_EditorFramesSinceUpdate = 0;
static int EditorFramesSinceUpdate => Application.isPlaying ? 0 : s_EditorFramesSinceUpdate;
internal static bool IsWithinEditorUpdate => EditorFramesSinceUpdate == 0;
internal bool IsSceneViewActive { get; set; }
int _LastFrameSceneCamera;
private protected override void Reset()
@@ -45,9 +57,37 @@ namespace WaveHarmonic.Crest
}
}
static void EditorUpdate()
{
// Do not execute when editor is not active to conserve power and prevent possible leaks.
if (!UnityEditorInternal.InternalEditorUtility.isApplicationActive)
{
return;
}
s_EditorFramesSinceUpdate++;
if (Instance == null) return;
if (!Application.isPlaying)
{
if ((Time.time - EditorTime) >= (1f / Mathf.Clamp(Instance._EditModeFrameRate, 0.01f, 120f)))
{
s_EditorFrames++;
s_EditorFramesSinceUpdate = 0;
EditorDeltaTime = Time.time - EditorTime;
EditorTime = Time.time;
Instance.RunUpdate();
}
}
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void OnDomainReload()
{
s_EditorFramesSinceUpdate = 0;
AfterRuntimeLoad();
}
@@ -62,10 +102,6 @@ namespace WaveHarmonic.Crest
{
switch (path)
{
case nameof(_MultipleViewpoints):
case nameof(_EditorMultipleViewpoints):
Rebuild();
break;
case nameof(_ExtentsSizeMultiplier):
case nameof(_GeometryDownSampleFactor):
Surface._Rebuild = true;