StoryM.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Localization.Settings;
  5. using UnityEngine.UI;
  6. public class StoryM : MonoBehaviour {
  7. public TMPro.TextMeshProUGUI textStory;
  8. public RectTransform panStory;
  9. void Start() {
  10. StartCoroutine(test());
  11. }
  12. IEnumerator SetStoryText(string textCh, string textEn = "English", float hideTime = 2f) {
  13. textStory.text = LocalizationSettings.SelectedLocale.LocaleName == "Chinese (Simplified) (zh-CN)" ? textCh : textEn;
  14. panStory.gameObject.SetActive(true);
  15. //LayoutRebuilder.ForceRebuildLayoutImmediate(panStory);
  16. //panStory.GetComponent<ContentSizeMininum>().Update();
  17. yield return new WaitForSeconds(hideTime);
  18. }
  19. public void HideStoryText() {
  20. panStory.gameObject.SetActive(false);
  21. }
  22. IEnumerator test() {
  23. while (true) {
  24. yield return StartCoroutine(SetStoryText("这是第一句话", "Eng" , 2f));
  25. yield return StartCoroutine(SetStoryText("这是第二句话,文本框大小改变了吗?"));
  26. HideStoryText();
  27. yield return new WaitForSeconds(2f);
  28. }
  29. }
  30. }