public void displayText(string unsplitLine) { NPCFaceRenderer.sprite = currentNode.getSprite(); string[] dialogue = unsplitLine.Split('|'); textBox.text = dialogue[0]; if (currentNode.getName() != "") { nameBox.text = currentNode.getName(); } if (currentButtonLayout != null) { currentButtonLayout.disableChildren(); } if (currentNode.getNumButtons() != 0 && currentNode.getNextNode() == -1) { //Well so much for elegance. To get the buttons to spawn on top of the text box and other things they need to be below them in the heirarcy //Before chilcount - 1 was pretty perfect, but now we use childcount + 2 because there are 3 more objects on top of the button layouts currentButtonLayout = transform.GetChild(currentNode.getNumButtons() + 2).gameObject.GetComponent <DisableButtonChildren>(); } else { currentButtonLayout = transform.GetChild(3).gameObject.GetComponent <DisableButtonChildren>(); } //didn't use foreach here because (reason) if (currentNode.getNextNode() == -1) { if (dialogue.Length > 1) { //didn't use foreach here because (reason) for (int i = 0; i < currentNode.getChildCount() && i + 1 < dialogue.Length; i++) { currentButtonLayout.transform.GetChild(i).GetComponentInChildren <Text>().text = dialogue[i + 1]; } } else { currentButtonLayout.transform.GetChild(0).GetComponentInChildren <Text>().text = ""; } } else { if (dialogue.Length > 1) { currentButtonLayout.transform.GetChild(0).GetComponentInChildren <Text>().text = dialogue[1]; } else { currentButtonLayout.transform.GetChild(0).GetComponentInChildren <Text>().text = ""; } } currentButtonLayout.enableChidlren(); }