namespace UIWidgets.Examples
{
using System;
using UnityEngine;
///
/// Test TimeAnalog.
///
public class TestTimeAnalog : MonoBehaviour
{
///
/// Time widget.
///
[SerializeField]
public TimeBase TimeWidget;
///
/// Text.
///
[SerializeField]
public TextAdapter Text;
///
/// Process the start event.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required")]
protected virtual void Start()
{
TimeWidget.OnTimeChanged.AddListener(TimeChanged);
TimeChanged(TimeWidget.Time);
}
///
/// Process the destroy event.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required")]
protected virtual void OnDestroy()
{
TimeWidget.OnTimeChanged.RemoveListener(TimeChanged);
}
///
/// Process the time changed event.
///
/// Time.
public void TimeChanged(TimeSpan time)
{
Text.text = string.Format("{0}:{1}", time.Hours.ToString("D02"), time.Minutes.ToString("D02"));
}
}
}