private IEnumerator DisplayBranch(DialogBranch dialogBranch, bool speech)
    {
        DialogPanel.SetActive(true);
        inputData.enabled = false;
        for (int i = 0; i < dialogBranch.blocks.Length; i++)
        {
            textArea.text = "";
            moreTextWidget.SetActive(false);
            if (speech)
            {
                dialogBranch.blocks[i].OnWrite.Invoke();
                for (int n = 1; n <= dialogBranch.blocks[i].text.Length; n++)
                {
                    textArea.text = dialogBranch.blocks[i].text.Substring(0, n);
                    yield return(new WaitForSecondsRealtime(1 / speechSpeed));

                    if (n > 5 && Input.anyKey)
                    {
                        n = dialogBranch.blocks[i].text.Length - 1;
                    }
                }
            }
            else
            {
                textArea.text = dialogBranch.blocks[i].text;
                dialogBranch.blocks[i].OnWrite.Invoke();
            }
            yield return(null);

            moreTextWidget.SetActive(true);
            while (!Input.anyKeyDown)
            {
                yield return(null);
            }
        }
        DialogPanel.SetActive(false);
        inputData.enabled = true;

        yield return(null);
    }
Ejemplo n.º 2
0
 public void NextBranch(bool option)
 {
     branchIdx     = option? branchIdx + 1 : branchIdx + 2;
     currentBranch = branches[branchIdx];
     lineIdx       = 0;
 }