namespace UIWidgets.Examples
{
using UIWidgets;
using UnityEngine;
///
/// Autocomplete test.
///
public class AutocompleteTest : MonoBehaviour
{
///
/// Autocomplete.
///
[SerializeField]
public AutocompleteString Autocomplete;
///
/// Adds listeners.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required.")]
protected virtual void Start()
{
// OptionSelected will be called when user select value
Autocomplete.OnOptionSelectedItem.AddListener(OptionSelected);
}
///
/// Process destroy event.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required.")]
protected virtual void OnDestroy()
{
Autocomplete.OnOptionSelectedItem.RemoveListener(OptionSelected);
}
///
/// Process selected text.
///
/// Selected text.
protected virtual void OptionSelected(string text)
{
// do something with text
Debug.Log(string.Format("Autocomplete selected value = {0}", text));
}
}
}