private void Start() { switch (pinType) { case PinType.Dialogue: GetComponent <Button>().onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenDialogueEditor(GetComponent <Button>()); }); break; case PinType.Quiz: GetComponent <Button>().onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenQuizEditor(GetComponent <Button>(), instantiatePanel("QuizEditorBG")); }); break; } }
// Adds listeners to the editor buttons // Opens the editor panel on click // Adds pin to Pin Area public void editorSelection(Button b, GameObject go, Sprite s) { Debug.Log(s.name); b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.assign(parent, go); }); b.onClick.AddListener(delegate { menu.gameObject.SetActive(false); }); b.onClick.AddListener(delegate { wipePins(); }); switch (s.name) { case "pin-dialogue": b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenDialogueEditor(b); }); //b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenDialogueEditor(b, instantiatePanel("DialogueEditorBG")); }); go.transform.name = "DialoguePin"; go.transform.Find("Item Background/ItemIcon").GetComponent <ToolTipInfoScript> ().tooltipName = "DialoguePin"; break; case "pin-quiz": b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenQuizEditor(b, instantiatePanel("QuizEditorBG")); }); //b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenQuizEditor(b); }); go.transform.name = "QuizPin"; go.transform.Find("Item Background/ItemIcon").GetComponent <ToolTipInfoScript> ().tooltipName = "QuizPin"; break; case "pin-mood": // Mood listener goes here break; case "pin-vitals": // Vital listener goes here break; case "pin-flag": b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenFlagEditor(b, instantiatePanel("FlagEventEditorBG")); }); go.transform.name = "FlagPin"; go.transform.Find("Item Background/ItemIcon").GetComponent <ToolTipInfoScript> ().tooltipName = "FlagPin"; break; case "pin-event": Image eventImg = go.transform.Find("Item Background").GetComponent <Image> (); b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenEventEditor(b, instantiatePanel("EventEditorBG")); }); b.onClick.AddListener(delegate { eventImg.color = new Color(255f, 0f, 0f); }); GameObject.Find("GaudyBG").GetComponent <FlagEventScript> ().eventImage = eventImg; go.transform.name = "EventPin"; go.transform.Find("Item Background/ItemIcon").GetComponent <ToolTipInfoScript> ().tooltipName = "EventPin"; break; default: Debug.Log("Pins have been renamed or need to be re-configured"); break; } }
/** * Directly loads the data into the data fields in the current tab */ private void LoadXMLData() { Transform[] allChildren = transform.gameObject.GetComponentsInChildren <Transform>(true); XmlNode node = xmlDoc.FirstChild; while (node.Value == null && !node.InnerText.Equals("")) { //Debug.Log (node.Name); if (node.Name.Equals("EntryData")) { if (node.NextSibling != null) { node = node.NextSibling; } else { while (node.ParentNode.NextSibling == null) { node = node.ParentNode; } node = node.ParentNode.NextSibling; if (node == xmlDoc.DocumentElement.LastChild) { return; } } } node = AdvNode(node); if (node == null) { Debug.Log("No Data to load."); return; } } //Assign values in spaces bool addDialogue = false; bool addQuiz = false; bool addFlag = false; bool addEvent = false; foreach (Transform child in allChildren) { //Debug.Log("CHILD: " + child.name); if (node != null && (child.name.Equals(node.ParentNode.Name) || (child.name.Equals(node.Name) && node.InnerXml.Equals("")))) { try { if (node.Value != null) { if (child.gameObject.GetComponent <InputField>() != null) { child.gameObject.GetComponent <InputField>().text = UnityWebRequest.UnEscapeURL(node.Value); } else if (child.gameObject.GetComponent <Text>() != null) { child.gameObject.GetComponent <Text>().text = UnityWebRequest.UnEscapeURL(node.Value); } else if (child.gameObject.GetComponent <Dropdown>() != null) { int indexValue = 0; foreach (Dropdown.OptionData myOptionData in child.gameObject.GetComponent <Dropdown>().options) { if (myOptionData.text.Equals(UnityWebRequest.UnEscapeURL(node.Value))) { break; } indexValue++; } child.gameObject.GetComponent <Dropdown>().value = indexValue; } else if (child.gameObject.GetComponent <Toggle>() != null) { child.gameObject.GetComponent <Toggle>().isOn = bool.Parse(node.Value); //child.gameObject.GetComponent<Text>().text = WWW.UnEscapeURL(node.Value); } else if (child.gameObject.GetComponent <Text>() != null) { child.gameObject.GetComponent <Text>().text = UnityWebRequest.UnEscapeURL(node.Value); } } node = AdvNode(node); while (node != null && node.Value == null && !node.InnerText.Equals("")) { if (Regex.IsMatch(node.Name.ToLower(), "tab[0-9]*$")) { break; } if (node.Name.Equals("EntryData") || node.Name.Equals("DialoguePin") || node.Name.Equals("QuizPin") || node.Name.Equals("FlagPin") || (node.Name.Equals("EventPin"))) { findUID(node); // Find uid node and use it as the key if (node.Name.Equals("DialoguePin")) { addDialogue = true; ds.AddDialogue(uid, node.OuterXml); } if (node.Name.Equals("QuizPin")) { addQuiz = true; XmlNode tempNode = node; while (!tempNode.Name.Equals("Parent")) { tempNode = AdvNode(tempNode); } ds.AddQuiz(tempNode.InnerText, node.InnerXml); } if (node.Name.Equals("FlagPin")) { addFlag = true; ds.AddFlag(uid, node.OuterXml); } if (node.Name.Equals("EventPin")) { addEvent = true; } if (node.NextSibling != null) { node = node.NextSibling; } else { if (node == null) { break; } if (node == xmlDoc.DocumentElement.LastChild) { break; } node = node.ParentNode.NextSibling; } } else { node = AdvNode(node); } } } catch (Exception e) { Debug.Log(e.Message); } } if (child.name.Equals("PinArea")) { if (addDialogue) { GameObject pinObj = Resources.Load(GlobalData.resourcePath + "/Prefabs/DialoguePinIcon") as GameObject; pinObj = Instantiate(pinObj, child); Button b = pinObj.AddComponent <Button>(); b.onClick.AddListener(delegate { /*b.onClick.AddListener(delegate {*/ ButtonListenerFunctionsScript.OpenDialogueEditor(b); //}); //b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenDialogueEditor(b, instantiatePanel("DialogueEditorBG")); }); }); pinObj.tag = "Value"; pinObj.name = "Dialogue" + "Pin"; addDialogue = false; } if (addQuiz) { GameObject pinObj = Resources.Load(GlobalData.resourcePath + "/Prefabs/QuizPinIcon") as GameObject; pinObj = Instantiate(pinObj, child); Button b = pinObj.AddComponent <Button>(); b.onClick.AddListener(delegate { //ButtonListenerFunctionsScript.OpenQuizEditor(b); //Delegate d = b.onClick.GetPersistentEventCount(); //d.GetInvocationList(); /*b.onClick.AddListener(delegate { */ ButtonListenerFunctionsScript.OpenQuizEditor(b, instantiatePanel("QuizEditorBG")); //}); }); pinObj.tag = "Value"; pinObj.name = "Quiz" + "Pin"; addQuiz = false; } if (addFlag) { GameObject pinObj = Resources.Load(GlobalData.resourcePath + "/Prefabs/FlagPinIcon") as GameObject; pinObj = Instantiate(pinObj, child); Button b = pinObj.AddComponent <Button>(); b.onClick.AddListener(delegate { //ButtonListenerFunctionsScript.OpenFlagEditor(b); b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenFlagEditor(b, instantiatePanel("FlagEventEditorBG")); }); }); pinObj.tag = "Value"; pinObj.name = "Flag" + "Pin"; addFlag = false; } if (addEvent) { GameObject pinObj = Resources.Load(GlobalData.resourcePath + "/Prefabs/EventPinIcon") as GameObject; pinObj = Instantiate(pinObj, child); Button b = pinObj.AddComponent <Button>(); b.onClick.AddListener(delegate { ButtonListenerFunctionsScript.OpenEventEditor(b, instantiatePanel("EventEditorBG")); }); pinObj.tag = "Value"; pinObj.name = "Event" + "Pin"; addEvent = false; } } } }