Skip to content

Instantly share code, notes, and snippets.

@ninpl
Created June 26, 2017 02:00
Show Gist options
  • Select an option

  • Save ninpl/7fca200db1f35c0fbd29a997e5b6c68f to your computer and use it in GitHub Desktop.

Select an option

Save ninpl/7fca200db1f35c0fbd29a997e5b6c68f to your computer and use it in GitHub Desktop.
Prediccion mediante un patron en C#
// ┌∩┐(◣_◢)┌∩┐
// \\
// 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;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment