Esempio n. 1
0
        private void StoryUpdate(Ballpoint.StoryUpdate update)
        {
            textDisplay.text = update.text;
            var hasChoices = update.choices.Count > 0;

            choicesParent.SetActive(hasChoices);
            nextButtonVisibilityContainer.SetActive(!hasChoices);
            if (hasChoices)
            {
                var buttons = choicesParent.GetComponentsInChildren <Button>();
                foreach (var button in buttons)
                {
                    button.gameObject.SetActive(false);
                }

                for (var i = 0; i < update.choices.Count; i++)
                {
                    var    buttonExists = i < buttons.Length;
                    Button button;
                    if (buttonExists)
                    {
                        button = buttons[i];
                    }
                    else
                    {
                        button = Instantiate(choicePrefab, choicesParent.transform);
                        var currentI = i; // if we don't do this, it uses the final value of i
                        button.onClick.AddListener(() => ink.Continue(currentI));
                    }
                    button.GetComponentInChildren <UnityEngine.UI.Text>().text = update.choices[i];
                    button.gameObject.SetActive(true);
                }
            }
        }
Esempio n. 2
0
 private void StoryUpdate(Ballpoint.StoryUpdate update) => speaker?.StoryUpdate(update);