Пример #1
0
        private IEnumerator DisplayNodeCoroutine(DialogNode node)
        {
            IsOpen = true;
            Texture2D avatar = node.GetAvatar();

            CharacterAvatar.sprite = Sprite.Create(avatar, new Rect(0f, 0f, avatar.width, avatar.height), Vector2.one / 2f);
            CharacterName.text     = node.Character.Name;
            ClearText();

            GenerateButtons(node);

            yield return(new WaitForSecondsRealtime(DialogStartWaitTime));

            yield return(AnimateText(node.Text));

            if (node.Options.Length == 0)
            {
                yield return(new WaitForSecondsRealtime(DialogEndWaitTime));

                IsOpen = false;
            }
        }
Пример #2
0
 private void GenerateButtons(DialogNode node)
 {
     foreach (Transform child in DialogOptionsParent)
     {
         if (child != VastNothingness)
         {
             Destroy(child.gameObject);
         }
     }
     foreach (DialogNode.Option option in node.Options)
     {
         GameObject go = Instantiate(DialogOptionPrefab, DialogOptionsParent);
         if (option.Result != null)
         {
             go.GetComponentInChildren <Button>().onClick.AddListener(option.OnSelected);
         }
         else
         {
             go.GetComponentInChildren <Button>().onClick.AddListener(EndDialog);
         }
         go.GetComponentInChildren <Text>().text = option.Text;
     }
 }
Пример #3
0
 public static void DisplayDialogNode(DialogNode node)
 {
     EndDialog();
     Instance._currentCoroutine = Instance.StartCoroutine(Instance.DisplayNodeCoroutine(node));
 }