private IEnumerator StartYell() { // Create an instance of a yell canvas if (YellUI == null) { Debug.LogError("Your Yell Handler does not have a yell dialog UI specified. Add a canvas that has a Text component as a child to this object", gameObject); yield break; } // Show the yell UI YellUI.SetActive(true); // Called now to orientate the yell to the camera otherwise there is a stutter Update(); // Set the yell canvas text TextMeshProUGUI text = YellUI.GetComponentInChildren <TextMeshProUGUI>(); // if (text == null) { throw new UnityException("Could not find a Text UI component in the specified Yell UI"); } // ConnectClickCallback(text.gameObject); foreach (FluentString str in CurrentNode.Sentences) { text.text = str; // Wait for the specified amount of seconds float elapsedTime = -1f; while (elapsedTime < CurrentNode.SecondsToPause && !interrupt) { elapsedTime += Time.deltaTime; yield return(null); } interrupt = false; } // FluentNode tempCurrentNode = CurrentNode; // Close the canvas CloseCanvas(); // CurrentNode = null; tempCurrentNode.Done(); }
public void End() { // Find the highest level Options node FluentNode highestOptionsNode = currentOptionsNode; while (highestOptionsNode.Parent is OptionsNode || highestOptionsNode.Parent is OptionNode) { highestOptionsNode = highestOptionsNode.Parent; } // Hide Hide(); // Call done on it highestOptionsNode.Done(); }
private IEnumerator StartYell() { // Create an instance of a yell canvas if (YellUI == null) { Debug.LogError("Your Yell Handler does not have a yell dialog UI specified. Add a canvas that has a Text component as a child to this object", gameObject); yield break; } // Show the yell UI YellUI.SetActive(true); // Called now to orientate the yell to the camera otherwise there is a hak Update(); // Set the yell canvas text Text text = YellUI.GetComponentInChildren <Text>(); // ConnectClickCallback(text.gameObject); if (text == null) { throw new UnityException("Could not find a Text UI component in the specified Yell UI"); } text.text = CurrentNode.Text; // Show the canvas for x seconds yield return(new WaitForSeconds(CurrentNode.SecondsToPause)); // FluentNode tempCurrentNode = CurrentNode; // Close the canvas CloseCanvas(); // CurrentNode = null; tempCurrentNode.Done(); }
void ConnectClickCallback(GameObject go) { if (go.GetComponentInChildren <Button>() == null) { go.AddComponent <Button>(); } // Add the button listener so that text can be skipped go.GetComponentInChildren <Button>().onClick.RemoveAllListeners(); go.GetComponentInChildren <Button>().onClick.AddListener(new UnityEngine.Events.UnityAction(() => { StopCoroutine("StartYell"); CloseCanvas(); FluentNode savedCurrentNode = CurrentNode; CurrentNode = null; savedCurrentNode.Done(); })); // Focus the button so that keypresses work EventSystem.current.SetSelectedGameObject(go); }