35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using OctoberStudio.Easing;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
|
|
namespace OctoberStudio.Rendering
|
|
{
|
|
/// <summary>
|
|
/// RendererAdapter 的便捷扩展方法。
|
|
/// 与 <see cref="OctoberStudio.Extensions.SpriteRendererExtensions"/> 对齐,方便逻辑层平滑迁移。
|
|
/// </summary>
|
|
public static class RendererAdapterExtensions
|
|
{
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static RendererAdapter SetAlpha(this RendererAdapter adapter, float alpha)
|
|
{
|
|
if (adapter != null) adapter.Alpha = alpha;
|
|
return adapter;
|
|
}
|
|
|
|
public static IEasingCoroutine DoAlpha(this RendererAdapter adapter, float targetAlpha, float duration, float delay = 0)
|
|
{
|
|
if (adapter == null) return null;
|
|
var initial = adapter.Alpha;
|
|
return new FloatEasingCoroutine(initial, targetAlpha, duration, delay, a => adapter.Alpha = a);
|
|
}
|
|
|
|
public static IEasingCoroutine DoColor(this RendererAdapter adapter, Color targetColor, float duration, float delay = 0)
|
|
{
|
|
if (adapter == null) return null;
|
|
var initial = adapter.Color;
|
|
return new ColorEasingCoroutine(initial, targetColor, duration, delay, c => adapter.Color = c);
|
|
}
|
|
}
|
|
}
|