/// <summary> /// Shows the text. /// </summary> /// <param name="sender">The InteractiveObject that called this</param> /// <param name="dialogKey">Dialog key.</param> /// <param name="fontSize">Font size.</param> public void showText(InteractiveObject sender, string dialogKey, int fontSize = 12) { curDialog = DialogEditor.GetDialog (dialogKey); if (curDialog == null) { Debug.LogWarning(string.Format("Dialog of key \"{0}\" not found", dialogKey)); return; } // Set text up isTextUp = true; // Reposition the text box based on the sender's position on screen if (Camera.main.WorldToScreenPoint (sender.transform.position).y < Screen.height / 2f) { textBox.transform.localPosition = new Vector3(0f, Screen.height / 4f, 0); } else { textBox.transform.localPosition = new Vector3(0f, -Screen.height / 4f, 0); } textBox.SetActive (true); textBox.transform.GetComponentInChildren<Text>().text = Localization.GetDialog (curDialog.contentKey); textBox.transform.GetComponentInChildren<Text> ().fontSize = fontSize; // Set the talker's name textBox.transform.GetChild (1).GetChild(0).GetComponent<Text> ().text = sender.getName(); textBox.GetComponent<Animator>().Play ("TextBoxAppear"); for (int i = 0; i < curDialog.responses.Count; i++) { setButton(sender, i); } }