Game3DInputField.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Game3DInputField : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private TextMesh placeholderCompontent;
  8. [SerializeField]
  9. private TextMesh textCompontent;
  10. private string _text;
  11. [SerializeField]
  12. public int maxLength;//字符数量
  13. public bool isPass;
  14. public string text
  15. {
  16. set
  17. {
  18. _text = value;
  19. if (isPass)
  20. {
  21. textCompontent.text = "";
  22. for (int i = 0; i < _text.Length; i++)
  23. {
  24. textCompontent.text += "*";
  25. }
  26. placeholderCompontent.gameObject.SetActive(_text == string.Empty);
  27. }
  28. else
  29. {
  30. textCompontent.text = _text;
  31. placeholderCompontent.gameObject.SetActive(_text == string.Empty);
  32. }
  33. }
  34. get
  35. {
  36. if (_text == null)
  37. _text = "";
  38. return _text;
  39. }
  40. }
  41. }