55 lines
1.5 KiB
C#
Raw Normal View History

2025-02-10 17:23:54 +08:00
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using XMLTool;
using TMPro;
using System.Drawing;
2025-02-11 16:42:39 +08:00
using System.Collections.Generic;
2025-02-10 17:23:54 +08:00
namespace QFramework.Example
{
public class UIBody3DData : UIPanelData
{
2025-02-11 16:42:39 +08:00
public Body3D.Body body = new Body3D.Body();
2025-02-10 17:23:54 +08:00
}
public partial class UIBody3D : UIPanel
{
protected override void OnInit(IUIData uiData = null)
{
// please add init code here
}
protected override void OnOpen(IUIData uiData = null)
{
2025-02-11 16:42:39 +08:00
mData = uiData as UIBody3DData ?? new UIBody3DData();
2025-02-10 17:23:54 +08:00
BodyContent.RemoveAllChildren();
2025-02-11 16:42:39 +08:00
Utility.FindObj(mData.body.Path).SetActive(true);
foreach (var body in mData.body.Children)
2025-02-10 17:23:54 +08:00
{
var bodyItem = GameObject.Instantiate(BodyItem.gameObject, BodyContent);
2025-02-11 16:42:39 +08:00
bodyItem.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = body.Name;
2025-02-10 17:23:54 +08:00
var bodyToggle = bodyItem.GetComponent<Toggle>();
2025-02-11 16:42:39 +08:00
bodyToggle.isOn = body.isShow;
2025-02-10 17:23:54 +08:00
bodyToggle.onValueChanged.AddListener(isOn =>
{
2025-02-11 16:42:39 +08:00
Utility.FindObj(body.Path).SetActive(isOn);
2025-02-10 17:23:54 +08:00
});
2025-02-11 16:42:39 +08:00
Utility.FindObj(body.Path).SetActive(body.isShow);
2025-02-10 17:23:54 +08:00
}
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
protected override void OnClose()
{
}
}
}