Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. // ┌∩┐(◣_◢)┌∩┐
  2. // \\
  3. // AutoPrediccion.cs (15/03/2017) \\
  4. // Autor: Antonio Mateo (Moon Antonio) \\
  5. // Descripcion: Prediccion mediante un patron \\
  6. // Fecha Mod: 15/03/2017 \\
  7. // Ultima Mod: Version Inicial \\
  8. //******************************************************************************\\
  9.  
  10. #region Librerias
  11. using UnityEngine;
  12. using System.Collections.Generic;
  13. #endregion
  14.  
  15. namespace MoonAntonio.Dev
  16. {
  17. /// <summary>
  18. /// <para>Prediccion mediante un patron.</para>
  19. /// </summary>
  20. [AddComponentMenu("Extensiones/Dev/AutoPrediccion")]
  21. public class AutoPrediccion : MonoBehaviour
  22. {
  23. #region Variables Publicas
  24. public UITextList textList;
  25. public UIInput mInput;
  26. public UILabel textAutocompletado;
  27. public List<string> comandos = new List<string>();
  28. public string texto = "";
  29. #endregion
  30.  
  31. private void Start()
  32. {
  33. mInput.label.maxLineCount = 1;
  34. }
  35.  
  36. private void Update()
  37. {
  38. Intellisent();
  39. }
  40.  
  41. public void Intellisent()
  42. {
  43. string oldString = texto;
  44. texto = mInput.value;
  45.  
  46. if (!string.IsNullOrEmpty(texto) && texto.Length > oldString.Length)
  47. {
  48. List<string> adivinando = comandos.FindAll(w => w.StartsWith(texto));
  49. if (adivinando.Count > 0)
  50. {
  51. textAutocompletado.text = adivinando[0];
  52. }
  53. }
  54.  
  55. if (Input.GetKeyDown(KeyCode.Tab))
  56. {
  57. mInput.value = textAutocompletado.text;
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement