/// <summary> 全文本显示 </summary> protected IEnumerator WaitForTextShowAllContent(bool word, Action cb) { DialogState = TextShowState.Read; DialogText.text = string.Empty; while (_lineIndex < _currentText.Count) { DialogText.text = string.Empty; if (word) { for (int i = 0; i < _currentText[_lineIndex].Length; i++) { DialogText.text += _currentText[_lineIndex][i]; yield return(_showSpeed); } } else { DialogText.text += _currentText[_lineIndex]; yield return(_showSpeed); } _lineIndex += 1; } DialogState = TextShowState.End; _lineIndex = 0; cb?.Invoke(); }
//some bugs /// <summary>单行文本显示 逐字显示</summary> protected IEnumerator WaitForTextShowSingleLine(bool word, Action cb) { DialogText.text = string.Empty; if (_currentText == null || _lineIndex >= _currentText.Count) { DialogState = TextShowState.None; yield return(null); } else { DialogState = TextShowState.Read; if (word) { for (int i = 0; i < _currentText[_lineIndex].Length; i++) { DialogText.text += _currentText[_lineIndex][i]; yield return(_showSpeed); } } else { DialogText.text += _currentText[_lineIndex]; yield return(_showSpeed); } _lineIndex += 1; if (_lineIndex >= _currentText.Count) { DialogState = TextShowState.End; } else { DialogState = TextShowState.LineEnd; } } cb?.Invoke(); }
protected override void Init() { _showSpeed = new WaitForSeconds(ShowTextSpeed); //初始设为true,即可以打开一个新的对话框 DialogState = TextShowState.None; }
/// <summary>重置</summary> public virtual void Restart() { _currentText = null; _lineIndex = 0; DialogState = TextShowState.None; }