84 lines
2.0 KiB
C#
84 lines
2.0 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using QFramework;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace QFramework.Example
|
|
{
|
|
public class UIImageSelectMap_JiHeData : UIPanelData
|
|
{
|
|
public string DragItemName;
|
|
public string TargetObj;
|
|
public string ItemPath;
|
|
}
|
|
|
|
public partial class UIImageSelectMap_JiHe : UIPanel
|
|
{
|
|
|
|
|
|
protected override void OnInit(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIImageSelectMap_JiHeData ?? new UIImageSelectMap_JiHeData();
|
|
loader = ResLoader.Allocate();
|
|
}
|
|
|
|
ResLoader loader;
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
{
|
|
string s = mData.DragItemName;
|
|
|
|
// 生成单个物体
|
|
GameObject obj = GameObject.Instantiate(LeftItem, LeftContent.transform);
|
|
obj.name = s;
|
|
|
|
string path = Global.deviceIconsPath + mData.ItemPath;
|
|
Debug.Log(path + "????");
|
|
loader.Add2Load(path.ToNetImageResName(), (success, res) =>
|
|
{
|
|
if (success)
|
|
{
|
|
obj.GetComponent<Image>().sprite = Utility.GetSprite(res.Asset as Texture2D);
|
|
obj.GetComponentInChildren<Text>().text = s;
|
|
}
|
|
});
|
|
|
|
uIImageDrag_JiHe = obj.GetComponent<UIImageDrag_JiHe>();
|
|
|
|
// 添加拖拽事件
|
|
//obj.OnBeginDragEvent(LeftOnBeginDrag);
|
|
//obj.OnDragEvent(LeftOnDrag);
|
|
//obj.OnEndDragEvent(LeftOnEndDrag);
|
|
|
|
loader.LoadAsync();
|
|
}
|
|
|
|
public UIImageDrag_JiHe uIImageDrag_JiHe;
|
|
|
|
|
|
// 重置拖拽状态
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
|
|
if (loader != null)
|
|
{
|
|
loader.Recycle2Cache();
|
|
loader = null;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |