private IEnumerator CDialogTxt(Interactible interactable, string[] dialog) { // Go through all dialog for (byte i = 0; i < dialog.Length; i++) { string[] words = dialog[i].Split(' '); bool wait = true; // used to auto skip (\-) bool autoNext = false; // used to automatically move to next dialog // Go through all words in single dialog for (uint j = 0; j < words.Length; j++) { bool specialAction = false; // Go through all chars for (uint k = 0; k < words[j].Length; k++) { if (words[j][(int)k] == _SPECIAL_CHAR) { switch (words[j][(int)k + 1]) { case _BIGGER_TEXT_SIZE_CHAR: _dialogTextPro.fontSize += 12; break; case _SMALLER_TEXT_SIZE_CHAR: _dialogTextPro.fontSize -= 12; break; case _TIME_WAIT_CHAR: yield return(new WaitForSeconds(ExtractTimeFromText(words[j], k))); break; case _SKIP_WAIT_CHAR: wait = !wait; break; case _CAM_SHAKE_CHAR: CameraActions.ActiveCamera?.Shake(); Debug.Log(CameraActions.ActiveCamera.gameObject.name); break; case _NEXT_CAM_CHAR: NextCam(); break; case _FIRST_CAM_CHAR: ResetCam(); break; case _AUTO_NEXT_CHAR: autoNext = true; break; default: Debug.LogWarning($"UNKNOWN TEXT COMMAND: {_SPECIAL_CHAR}{words[j][(int)k + 1]}"); break; } // Skip next space specialAction = true; } else if (words[j][(int)k] == _TMPRO_SPECIAL_CHAR_START) { for (uint m = 0; m < words[j].Length && words[j][(int)(k + m)] != _TMPRO_SPECIAL_CHAR_END; k++) { _dialogTextPro.text += words[j][(int)(k + m)]; } _dialogTextPro.text += _TMPRO_SPECIAL_CHAR_END; _dialogTextPro.text += ' '; // skip specialAction = true; } if (!specialAction) { if (wait) { yield return(new WaitForSeconds(Input.anyKey ? _SLOW_WRITE_SPEED / _TEXT_SPEED_UP_AMMOUNT : _SLOW_WRITE_SPEED)); } _dialogTextPro.text += words[j][(int)k]; } } if (!specialAction) { _dialogTextPro.text += ' '; } } if (!autoNext) { _nextDialogIndicatorAnim.SetTrigger("Display"); yield return(WaitForKeyPress()); _nextDialogIndicatorAnim.SetTrigger("Hide"); } if (i == dialog.Length - 1) { interactable.ExitInteraction(_activeCamIndex); } _dialogTextPro.fontSize = _defaultTextSize; _dialogTextPro.text = ""; _activeCamIndex = 0; // Next dialog screen (clear previous text) } yield return(null); }