升级6.4.升级水,升级天气

This commit is contained in:
2026-04-05 00:26:54 +08:00
parent 63bc9b5536
commit 5f7cbfb713
635 changed files with 34718 additions and 22567 deletions

View File

@@ -5,6 +5,7 @@ using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -13,15 +14,10 @@ namespace WaveHarmonic.Crest.Examples
#endif
[ExecuteAlways]
[RequireComponent(typeof(Camera))]
sealed class AlignSceneViewToCamera : MonoBehaviour
sealed class AlignSceneViewToCamera : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
#if UNITY_EDITOR
static int s_Scene;
static ulong s_Scene;
static bool s_SceneChanged;
[InitializeOnLoadMethod]
@@ -29,20 +25,22 @@ namespace WaveHarmonic.Crest.Examples
{
EditorSceneManager.sceneClosed -= OnSceneClosed;
EditorSceneManager.sceneClosed += OnSceneClosed;
s_Scene = SceneManager.GetActiveScene().handle;
s_Scene = SceneManager.GetActiveScene().GetRawSceneHandle();
}
static void OnSceneClosed(Scene a)
{
// TODO: Report to Unity
// Does not work if only game view is open. Handles will never update.
if (s_Scene == a.handle) return;
if (s_Scene == a.GetRawSceneHandle()) return;
s_SceneChanged = true;
s_Scene = a.handle;
s_Scene = a.GetRawSceneHandle();
}
void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
EditorApplication.update -= EditorUpdate;
EditorApplication.update += EditorUpdate;
}

View File

@@ -5,9 +5,22 @@
#define INPUT_SYSTEM_ENABLED
#endif
#if ENABLE_VR
#if UNITY_6000_5_OR_NEWER
#if d_UnityModuleXR
#define _XR_ENABLED
#endif
#else
#if d_UnityModuleVR
#define _XR_ENABLED
#endif
#endif
#endif
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -17,13 +30,8 @@ namespace WaveHarmonic.Crest.Examples
#if !CREST_DEBUG
[AddComponentMenu("")]
#endif
sealed class CameraController : MonoBehaviour
sealed class CameraController : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
float _LinearSpeed = 10f;
@@ -63,9 +71,10 @@ namespace WaveHarmonic.Crest.Examples
Transform _TargetTransform;
Camera _Camera;
void Awake()
private protected override void Awake()
{
base.Awake();
_TargetTransform = transform;
if (!TryGetComponent(out _Camera))
@@ -74,7 +83,7 @@ namespace WaveHarmonic.Crest.Examples
return;
}
#if ENABLE_VR && d_UnityModuleVR
#if _XR_ENABLED
if (XRSettings.enabled)
{
// Seems like the best place to put this for now. Most XR debugging happens using this component.
@@ -93,7 +102,7 @@ namespace WaveHarmonic.Crest.Examples
UpdateMovement(dt);
#if ENABLE_VR && d_UnityModuleVR
#if _XR_ENABLED
// These aren't useful and can break for XR hardware.
if (!XRSettings.enabled || XRSettings.loadedDeviceName.Contains("MockHMD"))
#endif
@@ -102,7 +111,7 @@ namespace WaveHarmonic.Crest.Examples
UpdateKillRoll();
}
#if ENABLE_VR && d_UnityModuleVR
#if _XR_ENABLED
if (XRSettings.enabled)
{
// Check if property has changed.

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5923ff6194bdd4740a68caa8ecad46d4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#if d_UnityInputSystem && ENABLE_INPUT_SYSTEM
#define INPUT_SYSTEM_ENABLED
#endif
using UnityEngine;
namespace WaveHarmonic.Crest.Examples
{
#if !CREST_DEBUG
[AddComponentMenu("")]
#endif
sealed class InputModulePatcher : MonoBehaviour
{
#if INPUT_SYSTEM_ENABLED
void OnEnable()
{
GetComponent<UnityEngine.EventSystems.StandaloneInputModule>().enabled = false;
}
#endif
}
}

View File

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

View File

@@ -13,11 +13,6 @@ namespace WaveHarmonic.Crest.Examples
{
#pragma warning disable IDE0032 // Use auto property
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
float _LerpAlpha = 0.1f;

View File

@@ -13,11 +13,6 @@ namespace WaveHarmonic.Crest.Examples
[AddComponentMenu(Constants.k_MenuPrefixSample + "Sample Displacement Demo")]
sealed class SampleDisplacementDemo : ManagedBehaviour<WaterRenderer>
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[Tooltip(ICollisionProvider.k_LayerTooltip)]
[SerializeField]
CollisionLayer _Layer;

View File

@@ -12,11 +12,6 @@ namespace WaveHarmonic.Crest.Examples
[AddComponentMenu(Constants.k_MenuPrefixSample + "Sample Height Demo")]
sealed class SampleHeightDemo : ManagedBehaviour<WaterRenderer>
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[Tooltip(ICollisionProvider.k_LayerTooltip)]
[SerializeField]
CollisionLayer _Layer;

View File

@@ -2,6 +2,7 @@
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -11,12 +12,10 @@ namespace WaveHarmonic.Crest.Examples
#if !CREST_DEBUG
[AddComponentMenu("")]
#endif
sealed class RandomMotion : MonoBehaviour
sealed class RandomMotion : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
bool _WorldSpace;
[Header("Translation")]
@@ -49,10 +48,11 @@ namespace WaveHarmonic.Crest.Examples
Vector3 _Origin;
Vector3 _OrthogonalAxis;
void Start()
private protected override void OnStart()
{
_Origin = transform.position;
base.OnStart();
_Origin = _WorldSpace ? transform.position : transform.localPosition;
_OrthogonalAxis = Quaternion.AngleAxis(90f, Vector3.up) * _Axis;
}
@@ -64,10 +64,21 @@ namespace WaveHarmonic.Crest.Examples
// Do circles in perlin noise
var rnd = 2f * (Mathf.PerlinNoise(0.5f + 0.5f * Mathf.Cos(_Frequency * Time.time), 0.5f + 0.5f * Mathf.Sin(_Frequency * Time.time)) - 0.5f);
// Prevent jump at start.
var amplitude = Mathf.Min(_Amplitude, _Amplitude * Time.timeSinceLevelLoad);
var orthoPhaseOff = Mathf.PI / 2f;
var rndOrtho = 2f * (Mathf.PerlinNoise(0.5f + 0.5f * Mathf.Cos(_Frequency * Time.time + orthoPhaseOff), 0.5f + 0.5f * Mathf.Sin(_Frequency * Time.time + orthoPhaseOff)) - 0.5f);
var position = _Origin + (_Axis * rnd + _OrthogonalMotion * rndOrtho * _OrthogonalAxis) * amplitude;
transform.position = _Origin + (_Axis * rnd + _OrthogonalMotion * rndOrtho * _OrthogonalAxis) * _Amplitude;
if (_WorldSpace)
{
transform.position = position;
}
else
{
transform.localPosition = position;
}
}
// Rotation

View File

@@ -3,6 +3,7 @@
using UnityEngine;
using UnityEngine.Rendering;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Editor
{
@@ -10,15 +11,16 @@ namespace WaveHarmonic.Crest.Editor
[AddComponentMenu("")]
#endif
[ExecuteAlways]
sealed class AmbientLightPatcher : MonoBehaviour
sealed class AmbientLightPatcher : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
#if UNITY_EDITOR
void OnEnable() => InitializeAmbientLighting();
private protected override void OnEnable()
{
base.OnEnable();
InitializeAmbientLighting();
}
void Update() => InitializeAmbientLighting();
bool _Baked;

View File

@@ -6,6 +6,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -14,26 +15,28 @@ namespace WaveHarmonic.Crest.Examples
[AddComponentMenu("")]
#endif
[ExecuteAlways, RequireComponent(typeof(PostProcessVolume))]
sealed class LegacyPostProcessingVolume : MonoBehaviour
sealed class LegacyPostProcessingVolume : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[@Layer]
[SerializeField]
int _Layer;
readonly List<PostProcessVolume> _QuickVolumes = new();
void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
if (!RenderPipelineHelper.IsLegacy)
{
return;
}
if (Helpers.IsWebGPU)
{
return;
}
_QuickVolumes.Clear();
foreach (var volume in GetComponents<PostProcessVolume>())

View File

@@ -4,10 +4,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
#if UNITY_EDITOR
using MonoBehaviour = WaveHarmonic.Crest.Internal.EditorBehaviour;
#endif
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Editor
{
@@ -16,13 +13,8 @@ namespace WaveHarmonic.Crest.Editor
#endif
[DefaultExecutionOrder(-1000)]
[ExecuteAlways]
sealed class LightingPatcher : MonoBehaviour
sealed class LightingPatcher : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
#if !CREST_DEBUG
[HideInInspector]
#endif
@@ -38,8 +30,10 @@ namespace WaveHarmonic.Crest.Editor
bool _CurrentLightsUseLinearIntensity;
bool _CurrentLightsUseColorTemperature;
void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
// SRP is always linear with temperature.
if (RenderPipelineHelper.IsLegacy)
{

View File

@@ -13,11 +13,6 @@ namespace WaveHarmonic.Crest.Editor
[RequireComponent(typeof(Camera))]
sealed class RenderPipelineCameraPatcher : RenderPipelinePatcher
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
#if UNITY_EDITOR
protected override void OnActiveRenderPipelineTypeChanged()
{

View File

@@ -16,11 +16,6 @@ namespace WaveHarmonic.Crest.Editor
[DefaultExecutionOrder(10)]
sealed class RenderPipelineLightPatcher : RenderPipelinePatcher
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
#if d_UnityHDRP
// For 2023.3 onwards, HDAdditionalLightData.intensity is obsolete and returns Light.intensity.
// It still serializes the old value so grab it via reflection.

View File

@@ -3,19 +3,18 @@
using UnityEngine;
using UnityEngine.Rendering;
#if UNITY_EDITOR
using MonoBehaviour = WaveHarmonic.Crest.Internal.EditorBehaviour;
#endif
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Editor
{
[ExecuteAlways]
abstract class RenderPipelinePatcher : MonoBehaviour
abstract class RenderPipelinePatcher : CustomBehaviour
{
#if UNITY_EDITOR
protected virtual void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
RenderPipelineManager.activeRenderPipelineTypeChanged -= OnActiveRenderPipelineTypeChanged;
RenderPipelineManager.activeRenderPipelineTypeChanged += OnActiveRenderPipelineTypeChanged;
}

View File

@@ -13,11 +13,6 @@ namespace WaveHarmonic.Crest.Editor
#endif
sealed class RenderPipelineSettingsPatcher : RenderPipelinePatcher
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[@AttachMaterialEditor]
[@DecoratedField, SerializeField]
Material _SkyBox;
@@ -30,7 +25,7 @@ namespace WaveHarmonic.Crest.Editor
base.Reset();
}
protected override void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
OnActiveRenderPipelineTypeChanged();

View File

@@ -11,11 +11,6 @@ namespace WaveHarmonic.Crest.Editor
#endif
sealed class RenderPipelineTerrainPatcher : RenderPipelinePatcher
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
Material _Material;
@@ -26,7 +21,7 @@ namespace WaveHarmonic.Crest.Editor
Material _MaterialURP;
#if UNITY_EDITOR
protected override void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
OnActiveRenderPipelineTypeChanged();

View File

@@ -12,11 +12,6 @@ namespace WaveHarmonic.Crest.Editor
#endif
sealed class RevertPrefabOnRenderPipelineChange : RenderPipelinePatcher
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
#if UNITY_EDITOR
private protected override void Awake()
{

View File

@@ -3,6 +3,7 @@
using UnityEngine;
using UnityEngine.Events;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -10,13 +11,8 @@ namespace WaveHarmonic.Crest.Examples
[AddComponentMenu("")]
#endif
[ExecuteAlways]
sealed class SendUnityEvent : MonoBehaviour
sealed class SendUnityEvent : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
float _ExecuteUpdateEvery;
@@ -44,8 +40,10 @@ namespace WaveHarmonic.Crest.Examples
float _TimeSinceEnabled;
float _LastUpdateTime;
void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
_TimeSinceEnabled = 0f;
_OnEnable.Invoke();

View File

@@ -2,6 +2,7 @@
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -11,13 +12,8 @@ namespace WaveHarmonic.Crest.Examples
#if !CREST_DEBUG
[AddComponentMenu("")]
#endif
sealed class SimpleMotion : MonoBehaviour
sealed class SimpleMotion : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
bool _ResetOnDisable;
@@ -35,8 +31,10 @@ namespace WaveHarmonic.Crest.Examples
Vector3 _OldPosition;
Quaternion _OldRotation;
void OnEnable()
private protected override void OnEnable()
{
base.OnEnable();
_OldPosition = transform.position;
_OldRotation = transform.rotation;
}

View File

@@ -2,6 +2,7 @@
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Examples
{
@@ -11,13 +12,8 @@ namespace WaveHarmonic.Crest.Examples
#if !CREST_DEBUG
[AddComponentMenu("")]
#endif
sealed class TimedDestroy : MonoBehaviour
sealed class TimedDestroy : CustomBehaviour
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[SerializeField]
float _LifeTime = 2.0f;
@@ -31,8 +27,10 @@ namespace WaveHarmonic.Crest.Examples
Vector3 _Scale;
float _BirthTime;
void Start()
private protected override void OnStart()
{
base.OnStart();
_BirthTime = Time.time;
_Scale = transform.localScale;
}

View File

@@ -30,6 +30,11 @@
"expression": "",
"define": "d_UnityModuleVR"
},
{
"name": "com.unity.modules.xr",
"expression": "",
"define": "d_UnityModuleXR"
},
{
"name": "com.unity.inputsystem",
"expression": "",