namespace UIWidgets
{
using System;
///
/// Base class for the SnapGrid.
///
public abstract partial class SnapGridBase : UIBehaviourConditional
{
///
/// Distance value to find value nearest to 0.
///
protected struct DistanceValue
{
///
/// Absolute value.
///
public float Abs
{
get;
private set;
}
///
/// Value.
///
public float Value
{
get;
private set;
}
///
/// Initializes a new instance of the struct.
///
/// Default value.
public DistanceValue(float defaultValue)
{
Abs = defaultValue;
Value = defaultValue;
}
///
/// Update value.
///
/// New value.
public void Update(float newValue)
{
var new_value_abs = Math.Abs(newValue);
if (new_value_abs < Abs)
{
Abs = new_value_abs;
Value = newValue;
}
}
}
}
}