using UnityEngine; using UnityEngine.UI; using QFramework; using XMLTool; using DG.Tweening; using TMPro; using System; namespace QFramework.Example { public class UIBody3DInfoData : UIPanelData { public Body3D.Body body; } public partial class UIBody3DInfo : UIPanel { GameObject obj; float bgH; protected override void OnInit(IUIData uiData = null) { TypeEventSystem.Global.Register(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this); bgH = Content.sizeDelta.y; Group.onValueChanged.AddListener(isOn => { TypeEventSystem.Global.Send(new OnBody3DGroupTypeChanged() { isGroup = isOn }); if (isOn) { Group.transform.Find("Label").GetComponent().text = "多选"; } else { Group.transform.Find("Label").GetComponent().text = "单选"; } }); Active.onValueChanged.AddListener(isOn => { obj.SetActive(isOn); if (isOn) { Active.transform.Find("Label").GetComponent().text = "隐藏"; } else { Active.transform.Find("Label").GetComponent().text = "显示"; } }); Transparent.onValueChanged.AddListener(isOn => { if (isOn) { Transparent.transform.Find("Label").GetComponent().text = "实体"; } else { Transparent.transform.Find("Label").GetComponent().text = "透明"; } Utility.SetSurfaceType(obj.GetComponent().material, isOn); }); Single.onClick.AddListener(() => { Body3DController.Instance.Active(false); BackBtn.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().text = "实体其他"; } else { TransparentOther.transform.Find("Label").GetComponent().text = "透明其他"; } Body3DController.Instance.Transparent(obj, isOn, true); }); BackBtn.onClick.AddListener(() => { Body3DController.Instance.Active(true); BackBtn.gameObject.SetActive(false); Active.gameObject.SetActive(true); Single.gameObject.SetActive(true); Transparent.gameObject.SetActive(true); TransparentOther.gameObject.SetActive(true); }); ShowTip.onValueChanged.AddListener(isOn => { if (isOn) { DOTween.To(() => Content.sizeDelta.y, (v) => { Content.sizeDelta = new Vector2(Content.sizeDelta.x, v); }, bgH + Center.sizeDelta.y, 0.2f); } else { DOTween.To(() => Content.sizeDelta.y, (v) => { Content.sizeDelta = new Vector2(Content.sizeDelta.x, v); }, bgH, 0.2f); } }); AudioBtn.onValueChanged.AddListener(isOn => { AudioSpeed.gameObject.SetActive(isOn); }); AudioSpeed.onValueChanged.AddListener((isOn) => { }); } private void OnModuleQuithandler(OnModuleQuit quit) { Hide(); } public void RefreshTipPath() { ListContent.RemoveAllChildren(); ListItemFacotry(mData.body); } public void Refresh() { PartName.text = mData.body.Name; obj = Utility.FindObj(mData.body.Path); Des.text = mData.body.Tip; RefreshTipPath(); } public void ListItemFacotry(Body3D.Body body) { GameObject obj = GameObject.Instantiate(ListItem.gameObject, ListContent); obj.transform.Find("Label").GetComponent().text = body.Name + ">"; obj.transform.SetAsFirstSibling(); if (body.parent != null) { ListItemFacotry(body.parent); } } protected override void OnOpen(IUIData uiData = null) { mData = uiData as UIBody3DInfoData ?? new UIBody3DInfoData(); Refresh(); } protected override void OnShow() { } protected override void OnHide() { } protected override void OnClose() { } } }