Ejemplo n.º 1
0
 public void ApplySettings(DialogSettings settings)
 {
     background.color      = settings.backgroundColor;
     nextCursor.blinkSpeed = settings.cursorBlinkSpeed;
     if (settings.showFrame)
     {
         frame.gameObject.SetActive(true);
         frame.sprite = settings.frameSprite;
     }
     else
     {
         frame.gameObject.SetActive(false);
     }
 }
Ejemplo n.º 2
0
        public static string PreprocessText(string text, DialogSettings settings)
        {
            if (settings.colorDictionary == null)
            {
                return(text);
            }
            var builder = new StringBuilder(text);

            foreach (var entry in settings.colorDictionary)
            {
                builder.Replace(entry.text, WrapWithColor(entry.text, entry.color));
            }
            return(builder.ToString());
        }
Ejemplo n.º 3
0
 public void ShowDialog(IList <string> pages, DialogSettings settings = null)
 {
     if (settings == null)
     {
         settings = baseSettings;
     }
     if (state != State.OFF)
     {
         Debug.LogWarning("Dialog already active, ignoring (Did you forget to check IsDialogActive?).");
         return;
     }
     if (pages.Count < 1 || pages[0].Length < 1)
     {
         Debug.LogWarning("DialogSystem: Ignoring empty text for ShowDialog()");
         return;
     }
     StartCoroutine(DialogRoutine(pages, settings));
 }
Ejemplo n.º 4
0
        private IEnumerator PageRoutine(string pageText, DialogSettings settings)
        {
            // Setup the page and wait until TMP processes it.
            yield return(dialogBox.LoadPageAsync(pageText));

            // Progressively reveal characters.
            Tuple <char, bool> result;

            while (!(result = dialogBox.Advance()).Item2)
            {
                if (settings.printSound != null)
                {
                    if (settings.soundOnWhitespace || !char.IsWhiteSpace(result.Item1))
                    {
                        audioSource.PlayOneShot(settings.printSound);
                    }
                }
                yield return(new WaitForSeconds(baseSettings.dialogSpeed));
            }
        }