颜色选择加入渐变

This commit is contained in:
ALIENJACK\alien 2024-11-14 20:07:24 +08:00
parent df32ff6a3a
commit 2c36f91725
2 changed files with 36 additions and 2 deletions

View File

@ -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;

View File

@ -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<float, float, FloatOptions> 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()