void HandleDisplayingTextbox() { // Create and initialize the textbox Debug.Log(this.name + " displaying textbox."); GameController.S.RequestGamePause(); textbox = Textbox.Create(textboxPrefab.gameObject); tbController = textbox.GetComponent <TextboxController>(); tbController.ApplyTextSettings(dialogueUI.textSettings); // Make sure the textbox shows up dialogueUI.needsDialogueCanvas.Add(this.gameObject); tbController.rectTransform.SetParent(dialogueCanvas.transform, false); tbController.nameTagText = "System"; HidePortrait(); PrepareForTextboxEnd(); tbController.gameObject.SetActive(false); // ^ Need to do this to avoid a weird visual effect. Don't worry, the textbox gets reenabled // right before it's time for it to display the text. StartCoroutine(DisplayTextDelayed(Time.deltaTime * 2)); }
void CreateTextbox() { if (textbox == null) { textbox = Textbox.Create(textboxPrefab); textboxController = textbox.GetComponent <TextboxController> (); textboxController.DoneDisplayingText.AddListener(ResumeDialogueRunning); EndedDialogue.AddListener(textboxController.Close); textbox.transform.SetParent(dialogueCanvas.transform, false); textboxController.PlaceOnScreen(new Vector2(0.5f, 0.0f)); if (textSettings.font != null) { textboxController.font = textSettings.font; } textSettings.Initialize(textboxController); textboxController.ApplyTextSettings(textSettings); // Have the textbox be invisible until it is time to show it CanvasGroup cGroup = textbox.AddComponent <CanvasGroup>(); cGroup.alpha = 0; cGroup.blocksRaycasts = false; } }