unity-atoms/Packages/Core/Runtime/Functions/Clamp/ClampInt.cs
Adam Ramberg 5d9f8dca71 WIP
2020-03-01 21:32:52 +01:00

35 lines
1.0 KiB
C#

using System;
using UnityEngine;
namespace UnityAtoms
{
/// <summary>
/// An `AtomFunction&lt;int, int&gt;` that clamps the value using a min and a max value and returns it.
/// </summary>
// [EditorIcon("atom-icon-sand")]
// [CreateAssetMenu(menuName = "Unity Atoms/Functions/Transformers/Clamp Int (int => int)", fileName = "ClampInt")]
// public class ClampInt : IntIntFunction, IIsValid
// {
// /// <summary>
// /// The minimum value.
// /// </summary>
// public IntReference Min;
// /// <summary>
// /// The maximum value.
// /// </summary>
// public IntReference Max;
// public override int Call(int value)
// {
// if (!IsValid()) { throw new Exception("Min value must be less than or equal to Max value."); }
// return Mathf.Clamp(value, Min.Value, Max.Value);
// }
// public bool IsValid()
// {
// return Min.Value <= Max.Value;
// }
// }
}