/// <summary>
/// Constrain the current target position to be within panel bounds.
/// </summary>
public bool ConstrainTargetToBounds(Transform target, ref Bounds targetBounds, bool immediate)
{
Vector3 offset = CalculateConstrainOffset(targetBounds.min, targetBounds.max);
if (offset.magnitude > 0f)
{
if (immediate)
{
target.localPosition += offset;
targetBounds.center += offset;
SpringPosition sp = target.GetComponent <SpringPosition>();
if (sp != null)
{
sp.enabled = false;
}
}
else
{
SpringPosition sp = SpringPosition.Begin(target.gameObject, target.localPosition + offset, 13f);
sp.ignoreTimeScale = true;
sp.worldSpace = false;
}
return(true);
}
return(false);
}