2025-02-13 11:02:16 +08:00

71 lines
2.0 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)
{
DragBtn.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
DragBack.gameObject.SetActive(true);
}
Body3DController.Instance.allowDrag = isOn;
TypeEventSystem.Global.Send<OnBody3DDragChanged>();
});
DragBack.onClick.AddListener(() =>
{
DragBtn.isOn = false;
DragBack.gameObject.SetActive(false);
});
}
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()
{
}
}
}