SubtitlesDisplayManager.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SubtitlesDisplayManager : MonoBehaviour
  5. {
  6. public string originalText
  7. {
  8. get
  9. {
  10. return this.originalUILabel.text;
  11. }
  12. set
  13. {
  14. this.Awake();
  15. if (this.originalText_ == value)
  16. {
  17. return;
  18. }
  19. this.originalUILabel.text = (this.originalText_ = ((!string.IsNullOrEmpty(value)) ? MessageClass.GetWrapString(this.originalUILabel, value) : string.Empty));
  20. if (this.displayType_ == SubtitlesDisplayManager.DisplayType.ON_OFF)
  21. {
  22. this.singleUILabel.text = this.originalText_;
  23. }
  24. }
  25. }
  26. public string subtitlesText
  27. {
  28. get
  29. {
  30. return this.subtitlesUILabel.text;
  31. }
  32. set
  33. {
  34. this.Awake();
  35. if (this.subtitlesText_ == value)
  36. {
  37. return;
  38. }
  39. this.subtitlesUILabel.text = (this.subtitlesText_ = ((!string.IsNullOrEmpty(value)) ? value : string.Empty));
  40. if (this.displayType_ == SubtitlesDisplayManager.DisplayType.OFF_ON)
  41. {
  42. this.singleUILabel.text = this.subtitlesText_;
  43. }
  44. }
  45. }
  46. public SubtitlesDisplayManager.DisplayType displayType
  47. {
  48. get
  49. {
  50. return this.displayType_;
  51. }
  52. set
  53. {
  54. this.Awake();
  55. this.displayType_ = value;
  56. if (this.displayType_ == SubtitlesDisplayManager.DisplayType.ON_ON)
  57. {
  58. this.twoTextAreaObject.SetActive(true);
  59. this.singleTextAreaObject.SetActive(false);
  60. }
  61. else if (this.displayType_ == SubtitlesDisplayManager.DisplayType.OFF_OFF)
  62. {
  63. this.twoTextAreaObject.SetActive(false);
  64. this.singleTextAreaObject.SetActive(false);
  65. }
  66. else if (this.displayType_ == SubtitlesDisplayManager.DisplayType.OFF_ON || this.displayType_ == SubtitlesDisplayManager.DisplayType.ON_OFF)
  67. {
  68. this.twoTextAreaObject.SetActive(false);
  69. this.singleTextAreaObject.SetActive(true);
  70. this.singleUILabel.text = ((this.displayType_ != SubtitlesDisplayManager.DisplayType.OFF_ON) ? this.originalText_ : this.subtitlesText_);
  71. }
  72. }
  73. }
  74. public bool visible
  75. {
  76. get
  77. {
  78. return base.gameObject.activeInHierarchy;
  79. }
  80. set
  81. {
  82. base.gameObject.SetActive(value);
  83. }
  84. }
  85. private void Awake()
  86. {
  87. if (this.callAwake)
  88. {
  89. return;
  90. }
  91. this.callAwake = true;
  92. string empty = string.Empty;
  93. this.subtitlesText = empty;
  94. this.originalText = empty;
  95. this.displayType = SubtitlesDisplayManager.DisplayType.ON_ON;
  96. }
  97. public void SetTextFromScriptStyle(string text)
  98. {
  99. if (string.IsNullOrEmpty(text))
  100. {
  101. string empty = string.Empty;
  102. this.subtitlesText = empty;
  103. this.originalText = empty;
  104. return;
  105. }
  106. KeyValuePair<string, string> translationText = MessageClass.GetTranslationText(text);
  107. this.originalText = translationText.Key;
  108. this.subtitlesText = translationText.Value;
  109. }
  110. [Header("日本語と翻訳,2テキスト表示する時の設定")]
  111. [SerializeField]
  112. private GameObject twoTextAreaObject;
  113. [SerializeField]
  114. private UILabel originalUILabel;
  115. [SerializeField]
  116. private UILabel subtitlesUILabel;
  117. [Header("日本語 or 翻訳の1テキストのみ表示する時の設定")]
  118. [SerializeField]
  119. private GameObject singleTextAreaObject;
  120. [SerializeField]
  121. private UILabel singleUILabel;
  122. private bool callAwake;
  123. private string originalText_;
  124. private string subtitlesText_;
  125. private SubtitlesDisplayManager.DisplayType displayType_;
  126. public enum DisplayType
  127. {
  128. ON_ON,
  129. OFF_OFF,
  130. OFF_ON,
  131. ON_OFF
  132. }
  133. }