Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ┌∩┐(◣_◢)┌∩┐
- // \\
- // AutoPrediccion.cs (15/03/2017) \\
- // Autor: Antonio Mateo (Moon Antonio) \\
- // Descripcion: Prediccion mediante un patron \\
- // Fecha Mod: 15/03/2017 \\
- // Ultima Mod: Version Inicial \\
- //******************************************************************************\\
- #region Librerias
- using UnityEngine;
- using System.Collections.Generic;
- #endregion
- namespace MoonAntonio.Dev
- {
- /// <summary>
- /// <para>Prediccion mediante un patron.</para>
- /// </summary>
- [AddComponentMenu("Extensiones/Dev/AutoPrediccion")]
- public class AutoPrediccion : MonoBehaviour
- {
- #region Variables Publicas
- public UITextList textList;
- public UIInput mInput;
- public UILabel textAutocompletado;
- public List<string> comandos = new List<string>();
- public string texto = "";
- #endregion
- private void Start()
- {
- mInput.label.maxLineCount = 1;
- }
- private void Update()
- {
- Intellisent();
- }
- public void Intellisent()
- {
- string oldString = texto;
- texto = mInput.value;
- if (!string.IsNullOrEmpty(texto) && texto.Length > oldString.Length)
- {
- List<string> adivinando = comandos.FindAll(w => w.StartsWith(texto));
- if (adivinando.Count > 0)
- {
- textAutocompletado.text = adivinando[0];
- }
- }
- if (Input.GetKeyDown(KeyCode.Tab))
- {
- mInput.value = textAutocompletado.text;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement