VirtualFramework/Assets/Scripts/UI/UI3DObjSelect.cs

59 lines
1.7 KiB
C#
Raw Normal View History

2025-02-11 16:42:39 +08:00
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using TMPro;
using UnityEngine.SceneManagement;
using System;
namespace QFramework.Example
{
public class UI3DObjSelectData : UIPanelData
{
}
public partial class UI3DObjSelect : UIPanel
{
protected override void OnInit(IUIData uiData = null)
{
mData = uiData as UI3DObjSelectData ?? new UI3DObjSelectData();
// please add init code here
}
protected override void OnOpen(IUIData uiData = null)
{
Content.RemoveAllChildren();
int index = 0;
2025-02-12 17:36:00 +08:00
foreach (var item in Global.Instance.curModule.body3d.parts)
2025-02-11 16:42:39 +08:00
{
GameObject obj = GameObject.Instantiate(BtnItem.gameObject, Content);
obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = item.Key;
obj.GetComponent<Button>().onClick.AddListener(() =>
{
2025-02-12 17:36:00 +08:00
Global.Instance.cur3DPart = Global.Instance.curModule.body3d.parts[item.Key];
TypeEventSystem.Global.Send<OnBody3DStart>();
2025-02-11 16:42:39 +08:00
UIBody3DData data = new UIBody3DData();
2025-02-12 17:36:00 +08:00
data.body = Global.Instance.cur3DPart;
2025-02-11 16:42:39 +08:00
UIKit.OpenPanelAsync<UIBody3D>(canvasLevel: UILevel.PopUI, uiData: data).ToAction().StartGlobal(() =>
{
Hide();
});
});
index++;
}
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
protected override void OnClose()
{
}
}
}