2025-06-26 14:07:29 +08:00

101 lines
2.6 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 System.Collections.Generic;
using System;
using System.Linq;
using TMPro;
using static OperationController;
namespace QFramework.Example
{
public class DragPanelData : UIPanelData
{
public string DragItemName;
public string HieraNames;
public string TargetObjs;
public string FinishedEvent;
}
public partial class DragPanel: UIPanel
{
public List<DragUIItem> dragUIItems=new List<DragUIItem>();
public Button NextButton;
//public string Finished;
protected override void OnInit(IUIData uiData = null)
{
// please add init code here
}
//private void OnStepChanged(StepStatusOnChange change)
//{
// Hide();
//}
protected override void OnOpen(IUIData uiData = null)
{
mData = uiData as DragPanelData ?? new DragPanelData();
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuit).UnRegisterWhenGameObjectDestroyed(gameObject);
//TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
NextButton.onClick.RemoveAllListeners();
NextButton.onClick.AddListener(() => {
StringEventSystem.Global.Send(mData.FinishedEvent);
Hide();
});
dragUIItems.Clear();
Content.transform.RemoveAllChildren();
List<String> DragItem = mData.DragItemName.Split('|')?.ToList();
List<String> ShowNames = mData.HieraNames.Split('|')?.ToList();
List<String> TargetObjs = mData.TargetObjs.Split('|')?.ToList();
var finished = mData.FinishedEvent;
for (int i = 0; i < DragItem.Count; i++)
{
int j = i;
var tipItemObj = GameObject.Instantiate(ItemPrefab, Content.transform);
tipItemObj.GetComponentInChildren<TextMeshProUGUI>().text = DragItem[j];
tipItemObj.name = ShowNames[j];
tipItemObj.GetComponent<DragUIItem>().targetName= TargetObjs[j];
tipItemObj.GetComponent<DragUIItem>().IsFirst = true;
dragUIItems.Add(tipItemObj.GetComponent<DragUIItem>());
}
}
protected override void OnShow()
{
Debug.Log("<22><>ʾ");
}
protected override void OnHide()
{
Debug.Log("<22><><EFBFBD><EFBFBD>");
}
protected override void OnClose()
{
// StringEventSystem.Global.Send(mData.FinishedEvent);
}
public void OnModuleQuit(OnModuleQuit arg)
{
Hide();
}
}
}