37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
#nullable enable
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UVC.UIToolkit
|
|
{
|
|
/// <summary>
|
|
/// Float 값과 Dropdown 선택 문자열을 함께 저장하는 구조체입니다.
|
|
/// UTKFloatDropdownPropertyItem의 값 타입으로 사용됩니다.
|
|
/// </summary>
|
|
public struct UTKFloatDropdownValue : IEquatable<UTKFloatDropdownValue>
|
|
{
|
|
/// <summary>Float 값</summary>
|
|
public float FloatValue { get; set; }
|
|
|
|
/// <summary>Dropdown 선택 값</summary>
|
|
public string DropdownValue { get; set; }
|
|
|
|
public UTKFloatDropdownValue(float floatValue, string dropdownValue)
|
|
{
|
|
FloatValue = floatValue;
|
|
DropdownValue = dropdownValue ?? "";
|
|
}
|
|
|
|
public bool Equals(UTKFloatDropdownValue other) =>
|
|
Mathf.Approximately(FloatValue, other.FloatValue) &&
|
|
string.Equals(DropdownValue, other.DropdownValue, StringComparison.Ordinal);
|
|
|
|
public override bool Equals(object? obj) => obj is UTKFloatDropdownValue other && Equals(other);
|
|
public override int GetHashCode() => HashCode.Combine(FloatValue, DropdownValue);
|
|
public override string ToString() => $"{FloatValue}{DropdownValue}";//$"{FloatValue:F2}{DropdownValue}";
|
|
|
|
public static bool operator ==(UTKFloatDropdownValue left, UTKFloatDropdownValue right) => left.Equals(right);
|
|
public static bool operator !=(UTKFloatDropdownValue left, UTKFloatDropdownValue right) => !left.Equals(right);
|
|
}
|
|
}
|