/// <summary> /// 更新已顯示在畫面上的文字, 切換語言時呼叫, 如果正在顯示文字中, 立即中斷顯示, 替換上目標語言 /// </summary> public void UpdateCurrentLangContent(SystemLanguage targetLanguage) { AdvManager.Instance.advWriter.StopDoWord(); if (string.IsNullOrEmpty(_onScreenNameTerm)) { NameText = ""; } else { string _name = LocalizeManager.GetLocalizeName(_onScreenNameTerm); NameText = string.IsNullOrEmpty(_name)? $"no key:{_onScreenNameTerm}" : _name; } //When initialize, the "_onScreenTextTerm" may be null if (string.IsNullOrEmpty(_onScreenTextTerm)) { StoryText = ""; } else { string _text = LocalizeManager.GetLocalizeText(_onScreenTextTerm); StoryText = string.IsNullOrEmpty(_text)? $"no key:{_onScreenTextTerm}" : _text; } }
public override void OnEnter() { if (!showAlways && executionCount >= showCount) { Continue(); return; } executionCount++; // Override the active say dialog if needed if (dataCharacter != null && dataCharacter.SetSayDialog != null) { SayDialog.ActiveSayDialog = character.SetSayDialog; } if (setSayDialog != null) { SayDialog.ActiveSayDialog = setSayDialog; } // Default say dialog is AdvManager's var sayDialog = AdvManager.Instance.advSayDialog; if (sayDialog == null) { Continue(); return; } var flowchart = GetComponent <FlowchartExtend>(); bool isRead = false; if (AdvManager.Instance.HasReadTable.TryGetValue($"{gameObject.name}.{csvCommandKey}", out isRead)) { hasRead = true; } sayDialog.SetActive(true); //1. Set name , color , portait string nameTerm = overrideTerm; string stringName = ""; if (!string.IsNullOrEmpty(overrideTerm)) { stringName = LocalizeManager.GetLocalizeName(overrideTerm); stringName = string.IsNullOrEmpty(stringName) ? $"no key:{overrideTerm}" : stringName; } Color nameColor; Color contentColor; nameColor = sayDialog.ColorName.TryGetValue(overrideTerm, out nameColor) ? nameColor : AdvProjectConfig.Instance.SaySpeakerColor; contentColor = sayDialog.ColorText.TryGetValue(overrideTerm, out contentColor) ? contentColor : AdvProjectConfig.Instance.SayContentColor; sayDialog.SetCharacter(stringName, nameColor, overridePortrait); sayDialog.SetStoryColor(contentColor); //2. Set Content text string displayText = storyText; string textTerm = $"{flowchart.GoogleSheetID}.{flowchart.GooglePageID}.{CSVCommandKey}"; string localText = LocalizeManager.GetLocalizeText(textTerm); if (!string.IsNullOrEmpty(localText)) { displayText = localText; } var activeCustomTags = CustomTag.activeCustomTags; for (int i = 0; i < activeCustomTags.Count; i++) { var ct = activeCustomTags[i]; displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith); if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "") { displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith); } } string subbedText = flowchart.SubstituteVariables(displayText); //displayText is origin Tag string , subbedText is Replace by Variables Text //3. Set Icon show / hide sayDialog.SetIconDisplay(showIcon); // //如果立繪中有存在這個 SpeakerTerm , 啟用立繪相關功能 // BillboardController billboardCtrl = null; // if(!string.IsNullOrEmpty(speakerTerm.ToString())){ // billboardCtrl = AdvManager.Instance.mainStage.BillboardLayout.FindBillboardWithTerm(speakerTerm); // } // if(billboardCtrl != null){ // //關閉頭相框 // sayDialog.SayIconObject.SetActive(false); // //從 atlas 取得說話表情 // billboardCtrl.SetRendererSprite(portrait); // AdvManager.Instance.mainStage.BillboardLayout.PopUpBillboard(billboardCtrl); // } // else // { // AdvManager.Instance.mainStage.BillboardLayout.ResumeBillboardPop(); // } //4. Set billboard on Stage UIBillboardController uiCtrl = null; if (!string.IsNullOrEmpty(overrideTerm)) { uiCtrl = AdvManager.Instance.advStage.BillboardGUILayout.FindBillboardWithTerm(overrideTerm); } if (uiCtrl != null) { //關閉頭相框 if (AdvProjectConfig.Instance.AlwaysHideIconWhenOnBillboard) { sayDialog.SayIconObject.SetActive(false); } if (overridePortrait) { uiCtrl.RuntimeSetEmoji(overridePortrait.name); } uiCtrl.RuntimeUnequip(); uiCtrl.RuntimeSetEquip(portraitEquip); } else { } sayDialog.SetLogInfo(nameTerm, textTerm, voiceOverClip); sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, hasRead, delegate { //已經確定讀完這句話了 AdvManager.Instance.OnSayRead?.Invoke(gameObject.name, csvCommandKey); hasRead = true; Continue(); }); }
public void UpdateUIContent(SystemLanguage targetLanguage) { if (AvatarIcon != null) { AvatarIcon.sprite = AvatarSprite; if (AvatarIcon.sprite == null) { AvatarBorder.gameObject.SetActive(false); } else { if (AvatarSprite.bounds.size.x > AvatarSprite.bounds.size.y) { AvatarIcon.rectTransform.sizeDelta = new Vector2(AvatarBorder.rectTransform.sizeDelta.x, AvatarBorder.rectTransform.sizeDelta.y * (AvatarSprite.bounds.size.y / AvatarSprite.bounds.size.x)); } else { AvatarIcon.rectTransform.sizeDelta = new Vector2(AvatarBorder.rectTransform.sizeDelta.x * (AvatarSprite.bounds.size.x / AvatarSprite.bounds.size.y), AvatarBorder.rectTransform.sizeDelta.y); } AvatarBorder.gameObject.SetActive(true); } } if (AvatarVoice == null) { BTNVoice.gameObject.SetActive(false); } else { BTNVoice.gameObject.SetActive(true); } if (UseDynamicNameColor) { Color nameColor; nameColor = AdvManager.Instance.advSayDialog.ColorName.TryGetValue(NameTerm, out nameColor) ? nameColor : AdvProjectConfig.Instance.SaySpeakerColor; TextName.color = nameColor; } if (UseDynamicContentColor) { Color ContentColor; ContentColor = AdvManager.Instance.advSayDialog.ColorText.TryGetValue(NameTerm, out ContentColor) ? ContentColor : AdvProjectConfig.Instance.SayContentColor; TextSay.color = ContentColor; } if (string.IsNullOrEmpty(NameTerm)) { TextName.text = ""; } else { string _name = LocalizeManager.GetLocalizeName(NameTerm); TextName.text = string.IsNullOrEmpty(_name) ? $"no key:{NameTerm}" : _name; } //When initialize, the "TextTerm" may be null if (string.IsNullOrEmpty(TextTerm)) { TextSay.text = ""; } else { string _text = LocalizeManager.GetLocalizeText(TextTerm); TextSay.text = string.IsNullOrEmpty(_text) ? $"no key:{TextTerm}" : _text; } }