using UnityEngine; namespace EditorAttributes { /// /// Attribute to display a numerical field as a specified unit and convert it to another unit /// public class UnitFieldAttribute : PropertyAttribute { public string DisplayUnit { get; private set; } public string ConversionUnit { get; private set; } /// /// Attribute to display a numerical field as a specified unit and convert it to another unit /// /// The unit to display in the inspector /// The unit to convert to public UnitFieldAttribute(Unit displayUnit, Unit conversionUnit) { DisplayUnit = displayUnit.ToString(); ConversionUnit = conversionUnit.ToString(); } /// /// Attribute to display a numerical field as a specified unit and convert it to another unit /// /// The custom unit to display in the inspector /// The unit to convert to public UnitFieldAttribute(string customDisplayUnit, Unit conversionUnit) { DisplayUnit = customDisplayUnit; ConversionUnit = conversionUnit.ToString(); } /// /// Attribute to display a numerical field as a specified unit and convert it to another unit /// /// The unit to display in the inspector /// The custom unit to convert to public UnitFieldAttribute(Unit displayUnit, string customConversionUnit) { DisplayUnit = displayUnit.ToString(); ConversionUnit = customConversionUnit; } /// /// Attribute to display a numerical field as a specified unit and convert it to another unit /// /// The custom unit to display in the inspector /// The custom unit to convert to public UnitFieldAttribute(string customDisplayUnit, string customConversionUnit) { DisplayUnit = customDisplayUnit; ConversionUnit = customConversionUnit; } } }