VirtualFramework/Assets/Scripts/UI/UI3DBodyInfo.cs
2025-02-13 11:02:16 +08:00

113 lines
3.5 KiB
C#

using UnityEngine;
using UnityEngine.UI;
using QFramework;
using XMLTool;
using DG.Tweening;
using TMPro;
namespace QFramework.Example
{
public class UI3DBodyInfoData : UIPanelData
{
public Body3D.Body body;
}
public partial class UI3DBodyInfo : UIPanel
{
GameObject obj;
protected override void OnInit(IUIData uiData = null)
{
Group.onValueChanged.AddListener(isOn =>
{
TypeEventSystem.Global.Send<OnBody3DGroupTypeChanged>(new OnBody3DGroupTypeChanged() { isGroup = isOn });
if (isOn)
{
Group.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "多选";
}
else
{
Group.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "单选";
}
});
Active.onValueChanged.AddListener(isOn =>
{
obj.SetActive(isOn);
if (isOn)
{
Active.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "隐藏";
}
else
{
Active.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "显示";
}
});
Transparent.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
Transparent.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "实体";
}
else
{
Transparent.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "透明";
}
Utility.SetSurfaceType(obj.GetComponent<MeshRenderer>().material, isOn);
});
Single.onClick.AddListener(() =>
{
Body3DController.Instance.Active(false);
Back.gameObject.SetActive(true);
Active.gameObject.SetActive(false);
Single.gameObject.SetActive(false);
Transparent.gameObject.SetActive(false);
TransparentOther.gameObject.SetActive(false);
});
TransparentOther.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
TransparentOther.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "实体其他";
}
else
{
TransparentOther.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "透明其他";
}
Body3DController.Instance.Transparent(obj, isOn, true);
});
Back.onClick.AddListener(() =>
{
Body3DController.Instance.Active(true);
Back.gameObject.SetActive(false);
Active.gameObject.SetActive(true);
Single.gameObject.SetActive(true);
Transparent.gameObject.SetActive(true);
TransparentOther.gameObject.SetActive(true);
});
}
protected override void OnOpen(IUIData uiData = null)
{
mData = uiData as UI3DBodyInfoData ?? new UI3DBodyInfoData();
PartName.text = mData.body.Name;
obj = Utility.FindObj(mData.body.Path);
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
protected override void OnClose()
{
}
}
}