Files
2025-09-02 11:08:15 +08:00

38 lines
1.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// UI/UIImageAnimator.cs
using UnityEngine;
using UnityEngine.UI;
using Base; // 引入Base命名空间以使用BaseAnimator
namespace UI
{
[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)
{
if (_image)
{
_image.sprite = sprite;
}
}
// [可选] 如果UIImageAnimator需要任何Awake后特有的初始化逻辑可以在这里重写
// protected override void Awake()
// {
// base.Awake(); // 确保调用基类的Awake
// // 子类特有的初始化
// }
}
}