81 lines
1.9 KiB
C#
81 lines
1.9 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream.FrameAnimation
|
|
{
|
|
internal interface IFrameAnimationTarget
|
|
{
|
|
bool IsValid { get; }
|
|
bool Enabled { get; set; }
|
|
Sprite Sprite { get; set; }
|
|
}
|
|
|
|
internal sealed class SpriteRendererFrameAnimationTarget : IFrameAnimationTarget
|
|
{
|
|
private readonly SpriteRenderer target;
|
|
|
|
public bool IsValid => target != null;
|
|
public bool Enabled
|
|
{
|
|
get => target != null && target.enabled;
|
|
set
|
|
{
|
|
if (target != null)
|
|
{
|
|
target.enabled = value;
|
|
}
|
|
}
|
|
}
|
|
public Sprite Sprite
|
|
{
|
|
get => target != null ? target.sprite : null;
|
|
set
|
|
{
|
|
if (target != null)
|
|
{
|
|
target.sprite = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public SpriteRendererFrameAnimationTarget(SpriteRenderer target)
|
|
{
|
|
this.target = target;
|
|
}
|
|
}
|
|
|
|
internal sealed class ImageFrameAnimationTarget : IFrameAnimationTarget
|
|
{
|
|
private readonly Image target;
|
|
|
|
public bool IsValid => target != null;
|
|
public bool Enabled
|
|
{
|
|
get => target != null && target.enabled;
|
|
set
|
|
{
|
|
if (target != null)
|
|
{
|
|
target.enabled = value;
|
|
}
|
|
}
|
|
}
|
|
public Sprite Sprite
|
|
{
|
|
get => target != null ? target.sprite : null;
|
|
set
|
|
{
|
|
if (target != null)
|
|
{
|
|
target.sprite = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public ImageFrameAnimationTarget(Image target)
|
|
{
|
|
this.target = target;
|
|
}
|
|
}
|
|
}
|