Example #1
0
    void Update()
    {
        if (story.canContinue)
        {
            while (story.canContinue)
            {
                entities.DisableInteraction();

                var paragraph = story.Continue();

                foreach (var tag in story.currentTags)
                {
                    ProcessTag(tag);
                }

                mainText.text += Format(paragraph);

                foreach (var warning in story.currentWarnings ?? Enumerable.Empty <string>())
                {
                    Debug.LogWarning(warning);
                }

                foreach (var error in story.currentErrors ?? Enumerable.Empty <string>())
                {
                    Debug.LogError(error);
                }
            }

            if (story.currentChoices.Any())
            {
                if (hideNextChoices)
                {
                    entities.EnableInteraction();
                    hideNextChoices = false;
                }
                else
                {
                    choiceText.text    = string.Join(string.Empty, story.currentChoices.Select((c, idx) => $"<link=\"{idx}\">{c.text}</link>\n"));
                    choiceText.enabled = true;
                }
            }
        }
    }