Merge remote-tracking branch 'origin/feat/inport-props' into feat/craft-discovery
# Conflicts: # Assets/External/Animated PBR Chest Demo/Materials/WoodChest.mat # Packages/com.distantlands.cozy.core/Content/Integration/Import for BiRP.unitypackage.meta # Packages/com.distantlands.cozy.core/Content/Integration/Import for HDRP.unitypackage.meta # Packages/com.distantlands.cozy.core/Content/Integration/Import for URP.unitypackage.meta
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using INab.BetterFog.URP;
|
||||
|
||||
namespace Ashwild.Environment
|
||||
{
|
||||
/// <summary>
|
||||
/// Ties INab Studio's Better Fog to the day/night cycle: every frame it copies the
|
||||
/// TimeOfDayManager's current sky colors into the Better Fog volume override so the fog
|
||||
/// warms at dawn/dusk and turns cool/dark at night along with the sky. This is the ONLY
|
||||
/// script that references the Better Fog asset — the manager itself stays fog-agnostic, so
|
||||
/// swapping the fog solution later only touches this file. Runs in edit mode so the fog
|
||||
/// tracks the time slider live.
|
||||
/// </summary>
|
||||
[ExecuteAlways]
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("GAME/Environment/Better Fog Day-Night Driver")]
|
||||
public class BetterFogDayNightDriver : MonoBehaviour
|
||||
{
|
||||
#region Serialized Fields
|
||||
|
||||
[Tooltip("Global Volume whose profile holds a Better Fog override.")]
|
||||
[SerializeField] private Volume fogVolume;
|
||||
[Tooltip("Push the current horizon color into Better Fog's Fog Color.")]
|
||||
[SerializeField] private bool driveFogColor = true;
|
||||
[Tooltip("Push the current sun color into Better Fog's Sun Color (only visible when Better Fog's Sun Light is enabled).")]
|
||||
[SerializeField] private bool driveSunColor = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region State
|
||||
|
||||
private BetterFogVolumeComponent fog;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity Lifecycle
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the Better Fog override once so Update can drive it cheaply, and warns if the
|
||||
/// wiring is incomplete instead of silently doing nothing.
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
ResolveFog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the manager's current palette into the fog override. No-op until both the fog
|
||||
/// volume and the manager exist, re-resolving the override if it was lost (profile swap).
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
if (fog == null && !ResolveFog()) return;
|
||||
if (TimeOfDayManager.Instance == null) return;
|
||||
|
||||
if (driveFogColor)
|
||||
{
|
||||
fog._FogColor.overrideState = true;
|
||||
fog._FogColor.value = TimeOfDayManager.Instance.CurrentHorizonColor;
|
||||
}
|
||||
|
||||
if (driveSunColor)
|
||||
{
|
||||
fog._SunColor.overrideState = true;
|
||||
fog._SunColor.value = TimeOfDayManager.Instance.CurrentSunColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the Better Fog override from the assigned volume's profile, logging a clear
|
||||
/// error when it is missing so the setup mistake is obvious. Returns true on success.
|
||||
/// </summary>
|
||||
private bool ResolveFog()
|
||||
{
|
||||
if (fogVolume == null)
|
||||
{
|
||||
Debug.LogError($"[BetterFogDayNightDriver] '{name}' has no Fog Volume assigned.", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fogVolume.profile == null || !fogVolume.profile.TryGet(out fog))
|
||||
{
|
||||
Debug.LogError($"[BetterFogDayNightDriver] '{name}' volume profile has no Better Fog override.", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user