VirtualFramework/Assets/Scripts/UI/UIBody3DInfo.cs

204 lines
6.0 KiB
C#
Raw Normal View History

2025-02-12 17:36:00 +08:00
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using XMLTool;
using DG.Tweening;
using TMPro;
2025-02-17 15:14:40 +08:00
using System;
2025-02-12 17:36:00 +08:00
namespace QFramework.Example
{
public class UIBody3DInfoData : UIPanelData
2025-02-12 17:36:00 +08:00
{
public Body3D.Body body;
}
public partial class UIBody3DInfo : UIPanel
2025-02-12 17:36:00 +08:00
{
2025-02-13 11:02:16 +08:00
GameObject obj;
2025-03-17 14:51:03 +08:00
ResLoader loader;
2025-02-12 17:36:00 +08:00
protected override void OnInit(IUIData uiData = null)
{
2025-03-11 10:33:07 +08:00
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
2025-03-17 14:51:03 +08:00
loader = ResLoader.Allocate();
2025-02-12 17:36:00 +08:00
Group.onValueChanged.AddListener(isOn =>
{
2025-03-14 11:24:44 +08:00
var text = Group.transform.Find("Label").GetComponent<TextMeshProUGUI>();
2025-02-12 17:36:00 +08:00
TypeEventSystem.Global.Send<OnBody3DGroupTypeChanged>(new OnBody3DGroupTypeChanged() { isGroup = isOn });
if (isOn)
{
2025-03-14 11:24:44 +08:00
text.color = Color.white;
text.text = "<22><>ѡ";
2025-02-12 17:36:00 +08:00
}
else
{
2025-03-14 11:24:44 +08:00
text.color = new Color(1f / 255f, 103f / 255f, 206f / 255f);
text.text = "<22><>ѡ";
2025-02-12 17:36:00 +08:00
}
});
Active.onValueChanged.AddListener(isOn =>
{
obj.SetActive(isOn);
if (isOn)
{
Active.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "<22><><EFBFBD><EFBFBD>";
}
else
{
Active.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = "<22><>ʾ";
}
});
Transparent.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
Transparent.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = <><CAB5>";
}
else
{
Transparent.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = <><CDB8>";
}
Utility.SetSurfaceType(obj.GetComponent<MeshRenderer>().material, isOn);
});
2025-03-14 11:24:44 +08:00
Single.onValueChanged.AddListener((isOn) =>
2025-02-12 17:36:00 +08:00
{
2025-03-14 11:24:44 +08:00
Body3DController.Instance.Active(!isOn);
2025-02-12 17:36:00 +08:00
});
TransparentOther.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
TransparentOther.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = <><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
else
{
TransparentOther.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = <><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
Body3DController.Instance.Transparent(obj, isOn, true);
});
2025-02-13 11:02:16 +08:00
2025-03-14 11:24:44 +08:00
//BackBtn.onClick.AddListener(() =>
//{
2025-02-13 11:02:16 +08:00
2025-03-14 11:24:44 +08:00
// Body3DController.Instance.Active(true);
// BackBtn.gameObject.SetActive(false);
// Active.gameObject.SetActive(true);
// Single.gameObject.SetActive(true);
// Transparent.gameObject.SetActive(true);
// TransparentOther.gameObject.SetActive(true);
//});
2025-02-17 15:14:40 +08:00
ShowTip.onValueChanged.AddListener(isOn =>
{
2025-03-14 11:24:44 +08:00
Center.gameObject.SetActive(isOn);
2025-02-17 15:14:40 +08:00
});
AudioBtn.onValueChanged.AddListener(isOn =>
{
2025-03-17 14:51:03 +08:00
if (isOn)
{
string audioName = mData.body.Audio;
if (string.IsNullOrEmpty(audioName) == false)
{
string path = Global.audioPath + audioName;
loader.Add2Load(path.ToLocalAudioResName(), (success, res) =>
{
if (success)
{
AudioKit.PlayVoice(res.Asset.As<AudioClip>(), false, onEndedCallback: () =>
{
AudioBtn.isOn = false;
});
}
});
loader.LoadAsync();
}
}
else
{
AudioKit.StopVoice();
}
2025-02-17 15:14:40 +08:00
});
AudioSpeed.onValueChanged.AddListener((isOn) =>
{
});
2025-03-14 11:24:44 +08:00
FontAdd.onClick.AddListener(() =>
{
if (Des.fontSize <= 31)
{
Des.fontSize++;
}
});
FontSub.onClick.AddListener(() =>
{
if (Des.fontSize > 1)
{
Des.fontSize--;
}
});
2025-02-13 11:02:16 +08:00
}
2025-03-11 10:33:07 +08:00
private void OnModuleQuithandler(OnModuleQuit quit)
{
Hide();
}
2025-02-17 15:14:40 +08:00
public void RefreshTipPath()
{
ListContent.RemoveAllChildren();
ListItemFacotry(mData.body);
}
public void Refresh()
2025-02-13 11:02:16 +08:00
{
PartName.text = mData.body.Name;
obj = Utility.FindObj(mData.body.Path);
2025-02-17 15:14:40 +08:00
Des.text = mData.body.Tip;
RefreshTipPath();
}
2025-02-13 11:02:16 +08:00
2025-02-17 15:14:40 +08:00
public void ListItemFacotry(Body3D.Body body)
{
GameObject obj = GameObject.Instantiate(ListItem.gameObject, ListContent);
2025-03-14 11:24:44 +08:00
obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = body.Name + "/";
2025-02-17 15:14:40 +08:00
obj.transform.SetAsFirstSibling();
if (body.parent != null)
{
ListItemFacotry(body.parent);
}
2025-02-12 17:36:00 +08:00
}
2025-02-17 15:14:40 +08:00
protected override void OnOpen(IUIData uiData = null)
{
mData = uiData as UIBody3DInfoData ?? new UIBody3DInfoData();
Refresh();
}
2025-02-12 17:36:00 +08:00
protected override void OnShow()
{
}
protected override void OnHide()
{
}
protected override void OnClose()
{
}
}
}