using System; using System.Collections.Generic; using UnityEngine; public class SubtitlesDisplayManager : MonoBehaviour { public string originalText { get { return this.originalUILabel.text; } set { this.Awake(); if (this.originalText_ == value) { return; } this.originalUILabel.text = (this.originalText_ = ((!string.IsNullOrEmpty(value)) ? MessageClass.GetWrapString(this.originalUILabel, value) : string.Empty)); if (this.displayType_ == SubtitlesDisplayManager.DisplayType.ON_OFF) { this.singleUILabel.text = this.originalText_; } } } public string subtitlesText { get { return this.subtitlesUILabel.text; } set { this.Awake(); if (this.subtitlesText_ == value) { return; } this.subtitlesUILabel.text = (this.subtitlesText_ = ((!string.IsNullOrEmpty(value)) ? value : string.Empty)); if (this.displayType_ == SubtitlesDisplayManager.DisplayType.OFF_ON) { this.singleUILabel.text = this.subtitlesText_; } } } public SubtitlesDisplayManager.DisplayType displayType { get { return this.displayType_; } set { this.Awake(); this.displayType_ = value; if (this.displayType_ == SubtitlesDisplayManager.DisplayType.ON_ON) { this.twoTextAreaObject.SetActive(true); this.singleTextAreaObject.SetActive(false); } else if (this.displayType_ == SubtitlesDisplayManager.DisplayType.OFF_OFF) { this.twoTextAreaObject.SetActive(false); this.singleTextAreaObject.SetActive(false); } else if (this.displayType_ == SubtitlesDisplayManager.DisplayType.OFF_ON || this.displayType_ == SubtitlesDisplayManager.DisplayType.ON_OFF) { this.twoTextAreaObject.SetActive(false); this.singleTextAreaObject.SetActive(true); this.singleUILabel.text = ((this.displayType_ != SubtitlesDisplayManager.DisplayType.OFF_ON) ? this.originalText_ : this.subtitlesText_); } } } public bool visible { get { return base.gameObject.activeInHierarchy; } set { base.gameObject.SetActive(value); } } private void Awake() { if (this.callAwake) { return; } this.callAwake = true; string empty = string.Empty; this.subtitlesText = empty; this.originalText = empty; this.displayType = SubtitlesDisplayManager.DisplayType.ON_ON; } public void SetTextFromScriptStyle(string text) { if (string.IsNullOrEmpty(text)) { string empty = string.Empty; this.subtitlesText = empty; this.originalText = empty; return; } KeyValuePair translationText = MessageClass.GetTranslationText(text); this.originalText = translationText.Key; this.subtitlesText = translationText.Value; } [Header("日本語と翻訳,2テキスト表示する時の設定")] [SerializeField] private GameObject twoTextAreaObject; [SerializeField] private UILabel originalUILabel; [SerializeField] private UILabel subtitlesUILabel; [Header("日本語 or 翻訳の1テキストのみ表示する時の設定")] [SerializeField] private GameObject singleTextAreaObject; [SerializeField] private UILabel singleUILabel; private bool callAwake; private string originalText_; private string subtitlesText_; private SubtitlesDisplayManager.DisplayType displayType_; public enum DisplayType { ON_ON, OFF_OFF, OFF_ON, ON_OFF } }