diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppSettings/BgColorSettings.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/AppSettings/BgColorSettings.cs index 712f9ff..8d0ac3f 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/AppSettings/BgColorSettings.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppSettings/BgColorSettings.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using DG.Tweening; +using System; +using System.Collections.Generic; using UnityEngine; namespace AxibugEmuOnline.Client @@ -60,6 +62,16 @@ namespace AxibugEmuOnline.Client ColorUtility.TryParseHtmlString(colorCodeStr2, out color2); } + public static XMBColor Lerp(XMBColor start, XMBColor endColor, float t) + { + var result = new XMBColor(); + result.Name = endColor.Name; + result.color1 = Color.Lerp(start.color1, endColor.color1, t); + result.color2 = Color.Lerp(start.color2, endColor.color2, t); + + return result; + } + public override int GetHashCode() { int hash = 17; diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/BgSettingsUI/BgSetting_Color.cs b/AxibugEmuOnline.Client/Assets/Script/UI/BgSettingsUI/BgSetting_Color.cs index 637fb0e..b2f1817 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/BgSettingsUI/BgSetting_Color.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/BgSettingsUI/BgSetting_Color.cs @@ -1,5 +1,8 @@ using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.UI; +using DG.Tweening; +using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; using System.Linq; using UnityEngine; @@ -66,9 +69,28 @@ namespace AxibugEmuOnline.Client ui.IconUI.GetMaterial().SetColor("_Color2", Color.color2); } + private static TweenerCore s_colorChangeTween; public override void OnFocus() { - App.settings.BgColor.CurrentColor = Color; + float progress = 0; + XMBColor start = App.settings.BgColor.CurrentColor; + XMBColor endColor = Color; + + if (s_colorChangeTween != null) + { + s_colorChangeTween.Kill(); + s_colorChangeTween = null; + } + s_colorChangeTween = DOTween.To(() => progress, (x) => + { + progress = x; + var lerpColor = XMBColor.Lerp(start, endColor, x); + App.settings.BgColor.CurrentColor = lerpColor; + }, 1, 1f).SetEase(Ease.OutCubic); + s_colorChangeTween.onComplete = () => + { + s_colorChangeTween = null; + }; } public override void OnExcute()