43 lines
986 B
C#
43 lines
986 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityGameFramework.Runtime;
|
|
|
|
namespace UI
|
|
{
|
|
public class BgForm : UGuiForm
|
|
{
|
|
[SerializeField] private Image _bgImage;
|
|
|
|
private Sprite _currentSprite;
|
|
|
|
protected override void OnOpen(object userData)
|
|
{
|
|
base.OnOpen(userData);
|
|
|
|
if (!(userData is BgFormContext context))
|
|
{
|
|
Log.Error("BgFormContext is invalid.");
|
|
return;
|
|
}
|
|
|
|
RefreshUI(context);
|
|
}
|
|
|
|
protected override void OnClose(bool isShutdown, object userData)
|
|
{
|
|
_currentSprite = null;
|
|
_bgImage.sprite = null;
|
|
|
|
base.OnClose(isShutdown, userData);
|
|
}
|
|
|
|
public void RefreshUI(BgFormContext context)
|
|
{
|
|
if (this._currentSprite == context.Sprite) return;
|
|
|
|
this._currentSprite = context.Sprite;
|
|
_bgImage.sprite = context.Sprite;
|
|
}
|
|
}
|
|
}
|