IEnumerator HandleEvent(aggrathon.vq360.data.Event currentEvent, float delay) { yield return(new WaitForSeconds(currentEvent.time + delay)); if (currentEvent.action != "") { HandleAction(currentEvent.action); } else { currentEvent.ScrambleOptions(); logger.LogInformation(currentEvent.GetOptionText()); uiLayer.ShowQuestion(currentEvent, scenarioFolder, HandleOption); } }
public void ShowQuestion(aggrathon.vq360.data.Event question, string folderpath, Action <aggrathon.vq360.data.Option> selectionCallback) { if (question.title != "") { transform.GetChild(0).gameObject.SetActive(true); transform.GetChild(0).GetComponentInChildren <Text>().text = question.title; } else { transform.GetChild(0).gameObject.SetActive(false); } if (question.options.Length >= transform.childCount) { DebugText.LogImportant("Too many options in question '" + question.title + "' (max " + (transform.childCount - 1) + ")"); aggrathon.vq360.data.Option[] opts = new aggrathon.vq360.data.Option[transform.childCount - 1]; System.Array.Copy(question.options, opts, transform.childCount - 1); question.options = opts; } options = question.options.Length; for (int i = 0; i < options; i++) { aggrathon.vq360.data.Option option = question.options[permutation.IterateNext(options)]; transform.GetChild(i + 1).GetComponent <VrButton>().Setup( option.text, option.image == "" ? "" : Path.Combine(folderpath, option.image), () => selectionCallback(option)); transform.GetChild(i + 1).gameObject.SetActive(true); } for (int i = question.options.Length + 1; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } RecalculatePositions(); gameObject.SetActive(true); permutation.Randomize(); }