添加 BgForm
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 956fafaa81c7caa4c840171e4e4488cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user