49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System;
|
|
using TMPro;
|
|
using TriLibCore.Extensions;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UVC.UI;
|
|
using XRLib;
|
|
|
|
namespace Studio.UI
|
|
{
|
|
public class UI_MQTTTestResultItem : MonoBehaviour
|
|
{
|
|
public Transform Item_Topic;
|
|
public UVCKeyValueItem Item_TopicPayload;
|
|
public UVCKeyValueItem Item_TopicPacketSize;
|
|
public Button expand;
|
|
public Button refresh;
|
|
|
|
private void Awake()
|
|
{
|
|
Item_Topic = transform.DeepFind<Transform>(nameof(Item_Topic));
|
|
Item_TopicPayload = transform.DeepFind<UVCKeyValueItem>(nameof(Item_TopicPayload));
|
|
Item_TopicPacketSize = transform.DeepFind<UVCKeyValueItem>(nameof(Item_TopicPacketSize));
|
|
|
|
refresh = Item_Topic.GetComponentInChildren<Button>();
|
|
expand = Item_TopicPayload.GetComponentInChildren<Button>();
|
|
expand.onClick.AddListener(OnClickExpandPayloadView);
|
|
}
|
|
|
|
private void OnClickExpandPayloadView()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
internal void SetResult(string topic, string message, string payload)
|
|
{
|
|
Debug.Log($"Set MQTT Test Result Item. Topic: {topic}, Message: {message}, Payload Length: {payload.Length}");
|
|
if(Item_Topic == null || Item_TopicPayload == null || Item_TopicPacketSize == null)
|
|
{
|
|
Debug.LogError("UI_MQTTTestResultItem: One or more UI elements are not assigned.");
|
|
return;
|
|
}
|
|
Item_Topic.DeepFind<TextMeshProUGUI>("Text_Topic").SetText(topic);
|
|
Item_TopicPayload.SetValue(payload);
|
|
Item_TopicPacketSize.SetValue(payload.Length.ToString());
|
|
}
|
|
}
|
|
}
|