Files
ChunilENG/Packages/com.tivadar.best.mqtt/Samples~/Generic Client/UIExtensions.cs
정영민 2dd5d814a7 update
2025-02-20 09:59:37 +09:00

40 lines
965 B
C#

using System;
using Best.MQTT.Packets;
using UnityEngine.UI;
namespace Best.MQTT.Examples
{
public static class UIExtensions
{
public static string GetValue(this InputField field)
{
var value = field.text;
return value;
}
public static string GetValue(this InputField field, string defaultValue)
{
var value = field.text;
return string.IsNullOrEmpty(value) ? defaultValue : value;
}
public static int GetIntValue(this InputField field, int defaultValue)
{
return int.TryParse(field.text, out var value) ? value : defaultValue;
}
public static bool GetBoolValue(this Toggle toggle)
{
return toggle.isOn;
}
public static QoSLevels GetQoS(this Dropdown dropdown)
{
return ((QoSLevels[])Enum.GetValues(typeof(QoSLevels)))[dropdown.value];
}
}
}