# TextValueUpdater

## API

```csharp
[Tooltip("Text before value")]
public string beforeValueText = "";
[Tooltip("Text after value")]
public string afterValueText = "";
[Tooltip("For example '0' -> only int values. '0.0' -> float values with 1 digit after dot")]
public string valueFormat = "0";

public float CurrentValue => currentValue;

/// <summary>
/// Updates text
/// </summary>
/// <param name="targetValue">future text value</param>
/// <param name="smoothUpdate">should we update text smooth or instant</param>
/// <param name="completeOldIfRunning">true -> set current value to target (if smooth fill)<br>
/// </br>false -> keep smooth text change from current value</param>
public TextValueUpdater UpdateTextSmooth(float targetValue, bool completeOldIfRunning = false);

/// <summary>
/// Instant test set (stops animation if was)
/// </summary>
public void UpdateTextInstant(float targetValue);

/// <summary>
/// Force stop updating text (smooth update)
/// </summary>
/// <param name="complete">should we complete coroutine (set target value to current)</param>
public void StopUpdate(bool complete);

/// <summary>
/// Set animation duration before animation start
/// </summary>
/// <param name="duration"></param>
/// <returns></returns>
public TextValueUpdater SetChangeDuration(float duration);

/// <summary>
/// Set ease curve of animation before it start
/// </summary>
public TextValueUpdater SetChangeCurve(AnimationCurve curve);

/// <summary>
/// Set start value before animation start
/// </summary>
public TextValueUpdater SetStartValue(float value);

/// <summary>
/// Add callback on text update finish
/// </summary>
public TextValueUpdater OnComplete(Action action);
```

## How to use

Add this script to object, set reference to text component.\
In the controller (other script) call methods from this class.

Example can be found here:\
**Assets\\\_Examples\Ready Scripts\BarUI and TextValueUpdater.scene**
