更新
This commit is contained in:
@@ -43,6 +43,46 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据颜色智能更新提示阴影:null 关闭,非 null 启用对应颜色。
|
||||
/// 避免相同颜色重复 tween 导致闪烁。
|
||||
/// </summary>
|
||||
public void UpdateHintShadow(Color? color)
|
||||
{
|
||||
if (color == null)
|
||||
{
|
||||
if (hintShadow.gameObject.activeSelf)
|
||||
{
|
||||
DisableHintShadow();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Color targetColor = color.Value;
|
||||
|
||||
if (hintShadow.gameObject.activeSelf)
|
||||
{
|
||||
// 已启用:仅在颜色差异足够大时 tween,避免每帧闪烁
|
||||
if (!ApproximatelyEqualColor(hintShadow.color, targetColor))
|
||||
{
|
||||
hintShadowTweener?.Kill();
|
||||
hintShadowTweener = hintShadow.DOColor(targetColor, 0.2f).Play();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EnableHintShadow(targetColor);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ApproximatelyEqualColor(Color a, Color b, float tolerance = 0.01f)
|
||||
{
|
||||
return Mathf.Abs(a.r - b.r) < tolerance
|
||||
&& Mathf.Abs(a.g - b.g) < tolerance
|
||||
&& Mathf.Abs(a.b - b.b) < tolerance
|
||||
&& Mathf.Abs(a.a - b.a) < tolerance;
|
||||
}
|
||||
|
||||
public void EnableSelectShadow()
|
||||
{
|
||||
selectShadow.gameObject.SetActive(true);
|
||||
|
||||
Reference in New Issue
Block a user