diff --git a/Assets/Scripts/FixSystemNew/Cable/CableMeshRenderer.cs b/Assets/Scripts/FixSystemNew/Cable/CableMeshRenderer.cs index f2a10ffa4..0ada43fc6 100644 --- a/Assets/Scripts/FixSystemNew/Cable/CableMeshRenderer.cs +++ b/Assets/Scripts/FixSystemNew/Cable/CableMeshRenderer.cs @@ -37,6 +37,7 @@ public class CableMeshRenderer : MonoBehaviour private float _tipTaperFraction; // 末端收窄段占全长比例(0 关闭) private float _tipTaperScale = 1f; + private Color _environmentTint = Color.white; private readonly List _vertices = new(1024); private readonly List _colors = new(1024); @@ -69,6 +70,14 @@ public class CableMeshRenderer : MonoBehaviour _bands = bands ?? System.Array.Empty(); } + /// + /// 设置动态网格的环境光色调。RGB 会调制各色带,Alpha 保持原值。 + /// + public void SetEnvironmentTint(Color tint) + { + _environmentTint = tint; + } + /// 末端宽度收窄:最后 fraction 段从全宽线性收到 scale 倍(线头略细于孔圈)。 public void SetTipTaper(float fraction, float scale) { @@ -124,7 +133,11 @@ public class CableMeshRenderer : MonoBehaviour { int baseIndex = _vertices.Count; float half = band.width * 0.5f; - Color32 color = band.color; + Color32 color = new Color( + band.color.r * _environmentTint.r, + band.color.g * _environmentTint.g, + band.color.b * _environmentTint.b, + band.color.a); for (int i = start; i < count; i++) { diff --git a/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs b/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs index 0dcf9098c..fc58d926e 100644 --- a/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs +++ b/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs @@ -699,6 +699,10 @@ public class PhysicCable : MonoBehaviour } // 插接时线缆末端由平头切面改为圆头端帽(线自身的圆头,同旧 LineRenderer),读作"插进孔里" + var panelLight = AibisDream.FixSystem.FixPanelSystem.Instance?.PanelLight; + _cableMesh.SetEnvironmentTint(panelLight != null + ? panelLight.CurrentEnvironmentTint + : Color.white); _cableMesh.UpdateMesh(src, count, FindTailStart(count), State == CableState.Plugged); } diff --git a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelLight.cs b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelLight.cs index 78e18b827..dba653a6a 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelLight.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelLight.cs @@ -32,6 +32,8 @@ namespace AibisDream.FixSystem private const string PANEL_LIGHT_OFF_SFX = "event:/ActionFB/light_flicker_off"; private const float MIN_FLICKER_INTERVAL = 3f; private const float MAX_FLICKER_INTERVAL = 8f; + private const float ENVIRONMENT_COLOR_INFLUENCE = 0.65f; + private const float ENVIRONMENT_INTENSITY_INFLUENCE = 0.35f; #endregion @@ -87,6 +89,38 @@ namespace AibisDream.FixSystem private Tween lightStateTransitionTween; private LightState currentState = LightState.Normal; + /// + /// 当前环境灯相对于 Normal 状态的实时色调。 + /// 用于无法直接接收 URP 2D Light 的动态网格等渲染对象。 + /// + public Color CurrentEnvironmentTint + { + get + { + if (environmentLight == null) return Color.white; + + float currentIntensity = Mathf.Max(0f, environmentLight.intensity); + if (currentIntensity <= Mathf.Epsilon) return Color.black; + + float intensityScale = currentIntensity / + Mathf.Max(0.01f, normalEnvironmentIntensity); + Color lightColor = environmentLight.color; + Color softenedColor = Color.Lerp( + Color.white, + new Color(lightColor.r, lightColor.g, lightColor.b, 1f), + ENVIRONMENT_COLOR_INFLUENCE); + float softenedIntensity = Mathf.Lerp( + 1f, + intensityScale, + ENVIRONMENT_INTENSITY_INFLUENCE); + return new Color( + softenedColor.r * softenedIntensity, + softenedColor.g * softenedIntensity, + softenedColor.b * softenedIntensity, + 1f); + } + } + #endregion #region 生命周期