SCKeyboard3DPrompt.cs 990 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace SC.XR.Unity.Module_Keyboard
  5. {
  6. public class SCKeyboard3DPrompt : SCKeyboardBasePrompt
  7. {
  8. public int PROMPT_PER_PAGE = 15;
  9. public RectTransform promptInput;
  10. public RectTransform maskRect;
  11. public override int GetChinese(string englishWords)
  12. {
  13. wordCount = ChineseIMEManager.Instance.GetWordCount(englishWords);
  14. return wordCount;
  15. }
  16. public override string GetChinese(int index)
  17. {
  18. return ChineseIMEManager.Instance.GetWord(index);
  19. }
  20. public override void SetEnteredText(string textStr)
  21. {
  22. alreadyInput.alignment = TextAnchor.MiddleCenter;
  23. alreadyInput.text = textStr;
  24. if ((KeyboardUtils.CaculateTextLength(textStr, alreadyInput) * 0.1) > maskRect.sizeDelta.x) { alreadyInput.alignment = TextAnchor.MiddleRight; }
  25. }
  26. }
  27. }