/// <summary> /// Set the answers based on the changed text provided. /// </summary> /// <param name="dc"></param> public void SetAnswers(string dc) { ClickableText clickText = textFieldObject.GetComponent <ClickableText>(); #if UNITY_EDITOR Undo.RecordObject(this, "Saved new Answers"); Undo.RecordObject(clickText, "Saved new Answers"); #endif dc = dc.Replace("\r", ""); textfield = textfield.Replace("\r", ""); answers = new List <string>(); _dcText = dc; string[] splitTrue = textfield.Split('|'); string[] splitText = dc.Split('|'); TextCreator[] texts = new TextCreator[0]; if (TryGetComponent <Tab>(out Tab tab)) { texts = tab.gameObject.GetComponentsInChildren <TextCreator>(); } int counter = 0; foreach (var t in texts) { if (t == this) { break; } else { counter += t.textLength; } } for (int i = 0; i < splitTrue.Length; i++) { if (splitText.Length <= i) { break; } if (splitTrue[i] != splitText[i]) { answers.Add(counter.ToString()); Debug.Log("Added Discrepancy:"); Debug.Log(splitText[i]); Debug.Log(splitTrue[i]); Debug.Log("###################################################"); } counter++; } textLength = splitTrue.Length - 1; clickText.SetAnswers(answers); #if UNITY_EDITOR PrefabUtility.RecordPrefabInstancePropertyModifications(this); PrefabUtility.RecordPrefabInstancePropertyModifications(clickText); #endif }
private void Start() { clickText = GetComponent <ClickableText>(); clickText.enabled = false; }