using DefaultNamespace; using DefaultNamespace.ProcessMode; using Framework.Manager; using MotionFramework; using System.Collections.Generic; using System.Linq; using TMPro; using UnityEngine; using UnityEngine.UI; public class AddAnswerSheet : MonoBehaviour { public Button btnAddAnswer; public Button btnDelete; public Button btnSave; public GameObject answerContent; public List answerContents = new List(); public List answers = new List(); /// /// 题目标题 /// public List Titletopic = new List(); private Framework.Dto.InventoryReversalVoucherAnalyzer inventoryReversalVoucherAnalyzer; public Button closeButton; public TMP_InputField[] pici; public TMP_InputField[] jine; public TMP_InputField[] jisuanguocheng; public TMP_InputField zongjiner; // Start is called before the first frame update void Start() { inventoryReversalVoucherAnalyzer = (Framework.Dto.InventoryReversalVoucherAnalyzer)MotionEngine.GetModule().materialTaskObj; if (btnAddAnswer) { btnAddAnswer.onClick.AddListener(AddAnswerContent); btnDelete.onClick.AddListener(DeleteAnswerContent); btnSave.onClick.AddListener(SaveAnswerContent); } closeButton.onClick.AddListener(delegate { TutorialGuideManager.Instance.HideGuide(); }); } bool isint = false; private void AddAnswerContent() { if (MotionEngine.GetModule().ExamName.Contains("ELP应用") && !isint) { TutorialGuideManager.Instance.TriggerNextGuide(); isint = true; } var newContent = Instantiate(answerContent) as GameObject; if (newContent) { newContent.SetActive(true); newContent.transform.parent = answerContent.transform.parent; newContent.transform.localScale = Vector3.one; newContent.transform.SetSiblingIndex(answerContents.Count); answerContents.Add(newContent); // if (MotionEngine.GetModule().ExamName == "违约索赔") // { // if (answerContents.Count < 3) // { // newContent.transform.GetChild(2).gameObject.SetActive(false); // } // } if (btnDelete) { btnDelete.gameObject.SetActive(true); } if (newContent.transform.GetChild(0).GetComponentInChildren()) { newContent.transform.GetChild(0).GetComponentInChildren(true).text = answerContents.Count.ToString(); } answerContent.SetActive(false); //修改item中输入框的名称,为了与框架流程中输入的名称匹配 for (int i = 0; i < answerContents.Count; i++) { for (int j = 0; j < Titletopic.Count; j++) { answerContents[i].transform.GetChild(j).name = Titletopic[j].text; //获取i中的子物体数量j等于Titletopic标题的数量 } } } } private void DeleteAnswerContent() { if (answerContents.Count > 0) { GameObject tempObj = answerContents[answerContents.Count - 1]; answerContents.RemoveAt(answerContents.Count - 1); DestroyImmediate(tempObj); if (answerContents.Count <= 0) { btnDelete.gameObject.SetActive(false); } } } private void SaveAnswerContent() { if (MotionEngine.GetModule().ExamName.Contains("ELP应用") && btnSave.name!= "btn_保存2") { TutorialGuideManager.Instance.TriggerNextGuide(); } answers.Clear(); if (MotionEngine.GetModule().ExamName == "违约索赔") { for (int i = 0; i < pici.Length; i++) { answers.Add(pici[i].text); answers.Add(jine[i].text); // answers.Add(jisuanguocheng[i].text); } answers.Add(zongjiner.text); // // // for (int i = 0; i < answerContents.Count; i++) // { // answers.Add(answerContents[i].transform.GetChild(0).GetComponent().text); // answers.Add(answerContents[i].transform.GetChild(1).GetComponent().text); // answers.Add(answerContents[i].transform.GetChild(2).GetComponent().text); // if (i < 2) // { // answers.Add(answerContents[i].transform.GetChild(0).GetComponent().text); // answers.Add(answerContents[i].transform.GetChild(1).GetComponent().text); // } // else // { // answers.Add(answerContents[i].transform.GetChild(0).GetComponent().text); // answers.Add(answerContents[i].transform.GetChild(1).GetComponent().text); // answers.Add(answerContents[i].transform.GetChild(2).GetComponent().text); // } // } } else { for (int i = 0; i < answerContents.Count; i++) { for (int j = 0; j < Titletopic.Count; j++) { if (answerContents[i].transform.GetChild(j).GetComponent() != null) { if (!answers.Contains(answerContents[i].transform.GetChild(j).GetComponent().text) && !string.IsNullOrEmpty(answerContents[i].transform.GetChild(j).GetComponent().text)) { answers.Add(answerContents[i].transform.GetChild(j).GetComponent().text); } } else if (answerContents[i].transform.GetChild(j).GetComponent() != null) { if (GameLauncher.Instance.examName.Contains("ELP应用") && inventoryReversalVoucherAnalyzer.formselection == "无资质" && answerContents[i].transform.GetChild(j).parent.name != "ELP页面1(Clone)") { if (answerContents[i].transform.GetChild(j).name == "True" && answerContents[i].transform.GetChild(j).GetComponent().isOn == false) { answers.Add("true"); } } else { answers.Add(answerContents[i].transform.GetChild(j).GetComponent().isOn.ToString().ToLower()); } } } } } bool istrue = MotionFramework.MotionEngine.GetModule().HandleClick(answers); Debug.Log(istrue); } public void NextGuide() { TutorialGuideManager.Instance.TriggerNextGuide(); } // Update is called once per frame void Update() { } }