2025-02-11 16:42:39 +08:00

55 lines
1.5 KiB
C#

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