102 lines
2.4 KiB
C#
102 lines
2.4 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)
|
|
{
|
|
|
|
|
|
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuit).UnRegisterWhenGameObjectDestroyed(gameObject);
|
|
}
|
|
|
|
ResLoader loader;
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
{
|
|
mData = uiData as UIImageSelectMap_JiHeData ?? new UIImageSelectMap_JiHeData();
|
|
loader = ResLoader.Allocate();
|
|
LeftContent.DestroyChildren();
|
|
uIImageDrag_JiHe = null;
|
|
|
|
Frame1.DestroyChildren();
|
|
Frame2.DestroyChildren();
|
|
|
|
Frame1.GetComponent<Image>().color = Color.white;
|
|
Frame2.GetComponent<Image>().color = Color.white;
|
|
// Destory(Kuang1.gameObject.GetComponentInChildren<UIImageDrag_JiHe>());
|
|
|
|
string s = mData.DragItemName;
|
|
|
|
// Éú³Éµ¥¸öÎïÌå
|
|
GameObject obj = GameObject.Instantiate(LeftItem, LeftContent.transform);
|
|
obj.name = s;
|
|
|
|
|
|
|
|
string path = Global.deviceIconsPath + mData.ItemPath;
|
|
|
|
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>();
|
|
|
|
|
|
CloseBtn.onClick.RemoveAllListeners();
|
|
CloseBtn.onClick.AddListener(() => {
|
|
Hide();
|
|
});
|
|
|
|
|
|
loader.LoadAsync();
|
|
}
|
|
|
|
public UIImageDrag_JiHe uIImageDrag_JiHe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
|
|
|
|
StringEventSystem.Global.Send("UIImageSelectMap_JiHeʹÓýáÊø");
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public void OnModuleQuit(OnModuleQuit arg)
|
|
{
|
|
Hide();
|
|
}
|
|
}
|
|
} |