2025-07-01 17:54:39 +08:00

114 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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[] Items=mData.DragItemName.Split("|");
string[] Targets = mData.TargetObj.Split("|");
string[] ItemPaths = mData.ItemPath.Split("|");
for (int i = 0; i < Items.Length; i++)
{
int v = i;
GameObject obj = GameObject.Instantiate(LeftItem, LeftContent.transform);
obj.name = Items[v];
string path = Global.deviceIconsPath + ItemPaths[v];
uIImageDrag_JiHe = obj.GetComponent<UIImageDrag_JiHe>();
uIImageDrag_JiHe.targetObjName = Targets[v];
loader.Add2Load(path.ToNetImageResName(), (success, res) =>
{
if (success)
{
obj.GetComponent<Image>().sprite = Utility.GetSprite(res.Asset as Texture2D);
obj.GetComponentInChildren<Text>().text = Items[v];
}
});
}
//obj.GetComponent<UIImageDrag_JiHe>().targetObjName=
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ʹ<65>ý<EFBFBD><C3BD><EFBFBD>");
}
protected override void OnClose()
{
}
public void OnModuleQuit(OnModuleQuit arg)
{
Hide();
}
}
}