//refresh the UI elements: public void RefreshUI() { if (!currentDialogue) { return; } messageText.text = currentDialogue.GetMessage(); foreach (Dialogue.Option option in currentDialogue.GetOptions()) { DialogueOptionUI optionUI = (inactiveOptions.Count > 0) ? inactiveOptions.Pop() : null; if (optionUI == null) { optionUI = Instantiate(optionUIPrefab); optionUI.transform.SetParent(optionUIParent.transform, true); optionUI.transform.localScale = Vector3.one; } activeOptions.Push(optionUI); optionUI.Init(option); } panel.SetActive(true); }
private void HandleDialogueOptionHit(DialogueOptionUI dialogueOption) { if (_dialogueBox.GetValue <bool>("_revealingOptions")) { return; } var selectedOption = _dialogueBox.GetSelectedOption(); var options = _dialogueBox.GetValue <List <DialogueOptionUI> >("_optionsUIElements"); options[selectedOption].SetSelected(false); _dialogueBox.SetValue("_selectedOption", options.IndexOf(dialogueOption)); dialogueOption.SetSelected(true); }
private static void PostDialogueOptionAwake(DialogueOptionUI __instance) { var text = __instance.GetComponentInChildren <Text>(); var collider = __instance.gameObject.AddComponent <BoxCollider>(); var rectTransform = text.GetComponent <RectTransform>(); var thickness = 10f; var height = 40; var width = rectTransform.rect.width; collider.size = new Vector3(width, height, thickness); collider.center = new Vector3(0, -height * 0.5f, thickness * 0.5f); MaterialHelper.MakeGraphicChildrenDrawOnTop(__instance.gameObject); }
public void Hide() { currentDialogue = null; currentNPC = null; panel.SetActive(false); AudioManager.instance.UpdateVoiceOver(false); while (activeOptions.Count > 0) { DialogueOptionUI nextOption = activeOptions.Pop(); nextOption.gameObject.SetActive(false); inactiveOptions.Push(nextOption); } }