From 2c36f91725c48ea3dda30255c78eccac807fdfbe Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 14 Nov 2024 20:07:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9C=E8=89=B2=E9=80=89=E6=8B=A9=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E6=B8=90=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Manager/AppSettings/BgColorSettings.cs | 14 ++++++++++- .../Script/UI/BgSettingsUI/BgSetting_Color.cs | 24 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) 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()