Created
March 15, 2017 03:45
-
-
Save ninpl/04efbb4232d7eb6497cda7acfaadd270 to your computer and use it in GitHub Desktop.
Prediccion mediante un patron en C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ┌∩┐(◣_◢)┌∩┐ | |
// \\ | |
// AutoPrediccion.cs (15/03/2017) \\ | |
// Autor: Antonio Mateo (Moon Pincho) \\ | |
// Descripcion: Prediccion mediante un patron \\ | |
// Fecha Mod: 15/03/2017 \\ | |
// Ultima Mod: Version Inicial \\ | |
//******************************************************************************\\ | |
#region Librerias | |
using UnityEngine; | |
using System.Collections.Generic; | |
#endregion | |
namespace MoonPincho.Dev | |
{ | |
/// <summary> | |
/// <para>Prediccion mediante un patron.</para> | |
/// </summary> | |
[AddComponentMenu("Pendulum/Dev/SConsola")] | |
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