/// /// Instantiates the given prefab and sets it up as a window. /// private void CreateWindow(GameObject prefab, string text, Color color, Entity speaker) { if (window) { Destroy(window.transform.parent.gameObject); } //create window speakerPos = null; if (speaker) { speakerPos = speaker.transform.position; } window = Instantiate(prefab).GetComponentInChildren <GUIWindowScripts>(); window.Activate(); window.transform.SetSiblingIndex(0); background = window.transform.Find("Background").GetComponent <RectTransform>(); var exit = background.transform.Find("Exit"); exit.GetComponent <Button>().onClick.AddListener(() => { endDialogue(); }); if (isInCutscene) { exit.gameObject.SetActive(false); } window.OnCancelled.AddListener(() => { endDialogue(); }); textRenderer = background.transform.Find("Text").GetComponent <Text>(); textRenderer.font = shellcorefont; // radio image if (window.GetComponentInChildren <SelectionDisplayHandler>()) { if (speaker) { DialogueViewTransitionIn(speaker); window.GetComponentInChildren <SelectionDisplayHandler>().AssignDisplay(speaker.blueprint, null, speaker.faction); window.transform.Find("Name").GetComponent <Text>().text = speaker.blueprint.entityName; } else { window.GetComponentInChildren <SelectionDisplayHandler>().gameObject.SetActive(false); window.transform.Find("Name").GetComponent <Text>().text = "Unknown Speaker"; } } // change text this.text = text.Replace("<br>", "\n"); characterCount = 0; nextCharacterTime = (float)(Time.time + timeBetweenCharacters); characterCount = 0; nextCharacterTime = (float)(Time.time + timeBetweenCharacters); textRenderer.color = color; if (speaker) { AudioManager.PlayClipByID("clip_typing"); } }