多轮审查评估
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using BaseGames.Localization;
|
||||
|
||||
namespace BaseGames.Dialogue
|
||||
{
|
||||
@@ -19,6 +20,7 @@ namespace BaseGames.Dialogue
|
||||
[SerializeField] private GameObject _speakerNamePanel; // 无名称时隐藏整个名称框
|
||||
[SerializeField] private GameObject _continuePrompt; // "▼" 图标,打字完成后显示
|
||||
[SerializeField] private Image _speakerPortrait; // 角色头像框
|
||||
[SerializeField] private AudioSource _voiceSource; // 语音播放源(可不配置)
|
||||
|
||||
private Coroutine _typingCoroutine;
|
||||
private DialogueLine _currentLine;
|
||||
@@ -40,7 +42,7 @@ namespace BaseGames.Dialogue
|
||||
bool hasSpeaker = !string.IsNullOrEmpty(line.speakerNameKey);
|
||||
if (_speakerNamePanel != null) _speakerNamePanel.SetActive(hasSpeaker);
|
||||
if (hasSpeaker && _speakerNameText != null)
|
||||
_speakerNameText.text = line.speakerNameKey;
|
||||
_speakerNameText.text = LocalizationManager.Get(line.speakerNameKey, "Dialogue");
|
||||
|
||||
// 头像
|
||||
if (_speakerPortrait != null)
|
||||
@@ -49,6 +51,17 @@ namespace BaseGames.Dialogue
|
||||
if (line.portraitSprite != null) _speakerPortrait.sprite = line.portraitSprite;
|
||||
}
|
||||
|
||||
// 语音播放
|
||||
if (_voiceSource != null)
|
||||
{
|
||||
_voiceSource.Stop();
|
||||
if (line.voiceClip != null)
|
||||
{
|
||||
_voiceSource.clip = line.voiceClip;
|
||||
_voiceSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
// 开始打字机协程
|
||||
if (_typingCoroutine != null) StopCoroutine(_typingCoroutine);
|
||||
_typingCoroutine = StartCoroutine(TypeLine(line));
|
||||
@@ -63,8 +76,9 @@ namespace BaseGames.Dialogue
|
||||
StopCoroutine(_typingCoroutine);
|
||||
_typingCoroutine = null;
|
||||
}
|
||||
_voiceSource?.Stop();
|
||||
if (_dialogueText != null)
|
||||
_dialogueText.text = _currentLine.textKey ?? "";
|
||||
_dialogueText.text = LocalizationManager.Get(_currentLine.textKey ?? "", "Dialogue");
|
||||
IsTyping = false;
|
||||
if (_continuePrompt != null) _continuePrompt.SetActive(true);
|
||||
}
|
||||
@@ -81,7 +95,7 @@ namespace BaseGames.Dialogue
|
||||
{
|
||||
IsTyping = true;
|
||||
float delay = line.typewriterDelay > 0f ? line.typewriterDelay : DefaultTypewriterDelay;
|
||||
string text = line.textKey ?? "";
|
||||
string text = LocalizationManager.Get(line.textKey ?? "", "Dialogue");
|
||||
|
||||
// 性能:StringBuilder 避免每帧字符串分配(O(n²) → O(n))
|
||||
var sb = new StringBuilder(text.Length);
|
||||
|
||||
Reference in New Issue
Block a user