80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using QFramework;
|
|
using UnityEngine.EventSystems;
|
|
using System.Drawing;
|
|
using static UnityEditor.Progress;
|
|
using DG.Tweening;
|
|
|
|
namespace QFramework.Example
|
|
{
|
|
public class UIImageTipData : UIPanelData
|
|
{
|
|
public bool isDrag = true;
|
|
public Vector2 size;
|
|
public string imgPath;
|
|
public Vector2 position;
|
|
}
|
|
public partial class UIImageTip : UIPanel
|
|
{
|
|
DOTweenAnimation loadingAnim;
|
|
protected override void OnInit(IUIData uiData = null)
|
|
{
|
|
loadingAnim = Loading.GetComponent<DOTweenAnimation>();
|
|
CloseBtn.onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
});
|
|
}
|
|
|
|
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIImageTipData ?? new UIImageTipData();
|
|
Loading.gameObject.SetActive(true);
|
|
loadingAnim.DOPlay();
|
|
Img.gameObject.SetActive(false);
|
|
Img.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
|
ResLoader loader = ResLoader.Allocate();
|
|
var localImageUrl = Global.imagePath + mData.imgPath;
|
|
loader.Add2Load(localImageUrl.ToNetImageResName(),
|
|
(bool success, IRes res) =>
|
|
{
|
|
if (success)
|
|
{
|
|
Img.sprite = Utility.GetSprite(res.Asset as Texture2D);
|
|
if (mData.size == default)
|
|
{
|
|
Img.SetNativeSize();
|
|
}
|
|
else
|
|
{
|
|
Img.rectTransform.sizeDelta = mData.size;
|
|
}
|
|
Img.gameObject.SetActive(true);
|
|
loadingAnim.DOPause();
|
|
Loading.gameObject.SetActive(false);
|
|
}
|
|
});
|
|
Img.GetComponent<UIDragItem>().enabled = mData.isDrag;
|
|
Img.rectTransform.anchoredPosition = mData.position;
|
|
loader.LoadAsync();
|
|
}
|
|
|
|
protected override void OnShow()
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
}
|
|
|
|
|
|
}
|
|
}
|