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(); 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().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().enabled = mData.isDrag; Img.rectTransform.anchoredPosition = mData.position; loader.LoadAsync(); } protected override void OnShow() { } protected override void OnHide() { } protected override void OnClose() { } } }