Function call on slider release?
<p>I use a slider to load historical data into my visualization application.  The slider represents a period in time relative to now.  So you can slide backwards in time and it will load data.</p>

<p>Currently, however, the data will load whenever the value of the slider changes which means if I want to see 5 hours ago?  I have to load everything in between...  </p>

<p>The code I am using is listed below:</p>

<pre><code>    history = LoadData.Historical();

    data = GameObject.Find("DataManager").GetComponent&lt;LoadData&gt;();

    slider.maxValue = history.Length - 1;
    slider.value = slider.maxValue;
    slider.onValueChanged.AddListener(delegate { ValueChange(); });
</code></pre>

<p>where ValueChange() contains something like this:</p>

<pre><code>    LoadData.Candles(data.bounds, history[(int)slider.value]);
</code></pre>

<p>Is there a way that I can only load the data when the value has been changed AND when I am not holding the slider?</p>

<p>Note: I have tried a coroutine method to achieve this, but it only ended in tears and infinite loops. :/</p>

<p>Edit:</p>

<p>I drafted this solution, but it seems OnMouseUp does not work directly on Sliders... Any ideas?</p>

<pre><code>void Start()
{

    slider = gameObject.GetComponent&lt;Slider&gt;();

    history = LoadData.Historical();

    data = GameObject.Find("DataManager").GetComponent&lt;LoadData&gt;();

    slider.maxValue = history.Length - 1;
    slider.value = slider.maxValue;
    slider.onValueChanged.AddListener(delegate { ValueChange(); });

    LoadData.Candles(data.bounds, history[(int)slider.maxValue]);

    valueChanged = false;
}

void OnMouseUp()
{
    Debug.Log("UP");
    if (valueChanged)
    {
        LoadData.DestroyCandles();
        LoadData.Candles(data.bounds, history[(int)slider.value]);
    }
    valueChanged = false;
}

void ValueChange()
{
    valueChanged = true;
    Debug.Log(valueChanged);
}
</code></pre>

<p>Edit2: </p>

<p><a href="https://i.stack.imgur.com/jVOsW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jVOsW.png" alt="enter image description here"></a></p>