(client) feat:状态UI
This commit is contained in:
38
Client/Assets/Scripts/Prefab/UIImageAnimator.cs
Normal file
38
Client/Assets/Scripts/Prefab/UIImageAnimator.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// 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
|
||||
// // 子类特有的初始化
|
||||
// }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user