SCKeyboard.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace SC
  6. {
  7. public class SCKeyboard : MonoBehaviour {
  8. public GameObject keyboard_num;
  9. public GameObject keyboard_symbol;
  10. public GameObject keyboard_enUp;
  11. public GameObject keyboard_enLow;
  12. private SCInputField input;
  13. private List<string> str;
  14. // Use this for initialization
  15. void Start () {
  16. gameObject.SetActive (false);
  17. str = new List<string> ();
  18. }
  19. public void show(SCInputField input, string value)
  20. {
  21. this.input = input;
  22. str = new List<string> ();
  23. for (int i = 0; i < value.Length; i++) {
  24. str.Add (value [i].ToString());
  25. }
  26. gameObject.SetActive (true);
  27. showEnLow ();
  28. }
  29. public void onClick(string value)
  30. {
  31. str.Add (value);
  32. setTextString ();
  33. }
  34. public void clear()
  35. {
  36. str = new List<string> ();
  37. setTextString ();
  38. }
  39. public void done()
  40. {
  41. str = new List<string> ();
  42. gameObject.SetActive (false);
  43. }
  44. public void del()
  45. {
  46. if (str.Count > 0) {
  47. str.RemoveAt (str.Count - 1);
  48. setTextString ();
  49. }
  50. }
  51. public void showNum()
  52. {
  53. keyboard_num.SetActive(true);
  54. keyboard_symbol.SetActive(false);
  55. keyboard_enUp.SetActive(false);
  56. keyboard_enLow.SetActive(false);
  57. }
  58. public void showSymbol()
  59. {
  60. keyboard_num.SetActive(false);
  61. keyboard_symbol.SetActive(true);
  62. keyboard_enUp.SetActive(false);
  63. keyboard_enLow.SetActive(false);
  64. }
  65. public void showEnUp()
  66. {
  67. keyboard_num.SetActive(false);
  68. keyboard_symbol.SetActive(false);
  69. keyboard_enUp.SetActive(true);
  70. keyboard_enLow.SetActive(false);
  71. }
  72. public void showEnLow()
  73. {
  74. keyboard_num.SetActive(false);
  75. keyboard_symbol.SetActive(false);
  76. keyboard_enUp.SetActive(false);
  77. keyboard_enLow.SetActive(true);
  78. }
  79. private void setTextString()
  80. {
  81. string text = "";
  82. for (int i = 0,l = str.Count; i < l; i++) {
  83. text += str [i];
  84. }
  85. input.text = text;
  86. }
  87. }
  88. }