2025-02-12 17:36:00 +08:00

57 lines
1.6 KiB
C#

using UnityEngine;
using UnityEngine.UI;
using QFramework;
using XMLTool;
using TMPro;
using System.Drawing;
using System.Collections.Generic;
using DG.Tweening;
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 bodyData in mData.body.subBody)
{
var body = bodyData.Value;
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;
GameObject obj = Utility.FindObj(body.Path);
obj.SetActive(body.isShow);
bodyToggle.onValueChanged.AddListener(isOn =>
{
obj.SetActive(isOn);
});
}
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
protected override void OnClose()
{
}
}
}