2025-09-03 19:59:22 +08:00
|
|
|
// UI/UIImageAnimator.cs
|
2025-09-19 08:26:54 +08:00
|
|
|
|
|
|
|
|
using Base;
|
2025-09-03 19:59:22 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
2025-09-19 08:26:54 +08:00
|
|
|
// 引入Base命名空间以使用BaseAnimator
|
|
|
|
|
|
|
|
|
|
namespace Prefab
|
2025-09-03 19:59:22 +08:00
|
|
|
{
|
|
|
|
|
[RequireComponent(typeof(Image))]
|
|
|
|
|
public class UIImageAnimator : BaseAnimator // 继承BaseAnimator
|
|
|
|
|
{
|
|
|
|
|
private Image _image; // UI Image组件
|
|
|
|
|
|
|
|
|
|
protected override void ValidateComponent()
|
|
|
|
|
{
|
|
|
|
|
_image = GetComponent<Image>();
|
|
|
|
|
if (_image == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("UIImageAnimator requires an Image component.", this);
|
|
|
|
|
enabled = false; // 禁用脚本如果组件缺失
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetDisplaySprite(Sprite sprite)
|
|
|
|
|
{
|
2025-10-03 00:31:34 +08:00
|
|
|
_image.sprite = sprite;
|
2025-09-03 19:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|