public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); serializedObject.Update(); SerializedProperty iterator = serializedObject.GetIterator(); LocalizedText text = target as LocalizedText; if (text != null) { if (this.zhString != text.GetText()) { this.zhString = text.GetText(); } text.SerializeZhText(this.zhString); } for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { if (iterator.name == "m_zhText") { EditorGUILayout.LabelField("zhText", iterator.stringValue, new GUILayoutOption[0]); } else if (iterator.name == "m_key") { EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); string key = iterator.stringValue; string localizedString = LocalizationImporter.GetLanguages(key); if (string.IsNullOrEmpty(zhString)) { zhString = localizedString; } EditorGUILayout.LabelField("中文", localizedString, new GUILayoutOption[0]); if (!string.IsNullOrEmpty(zhString) && zhString != localizedString) { DrawValuesAutoComplete(iterator, zhString); } } } serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { if (text != null) { text.OnLocalize(); } } }
public bool CheckMustContainMatch(string attempt, TextMustContainAnswer answerObj) { if (string.IsNullOrEmpty(attempt)) { attempt = ""; } var isCorrect = false; foreach (var locText in answerObj.AnswerText) { var answer = LocalizedText.GetText(locText).Trim(); if (answerObj.EnforceCase) { isCorrect = attempt.Contains(answer); } else { var answer_lower = answer.ToLower(); var attempt_lower = attempt.ToLower(); isCorrect = attempt_lower.Contains(answer_lower); } if (isCorrect) { break; } } return(isCorrect); }
public void AttemptsExhausted_Callback() { if (Data == null || Data.Quiz == null || Data.Quiz.Answer == null || Data.Quiz.Answer.AnswerText == null || Data.Quiz.Answer.AnswerText.Count() <= 0) { throw new Exception("No Answers assigned to this Quiz"); } var answerString = LocalizedText.GetText( Data.Quiz.Answer.AnswerText.FirstOrDefault()); if (string.IsNullOrEmpty(answerString)) { throw new Exception("Unable to parse answer string."); } if (!AnswerText) { m_logger.Warning(string.Format("No Answer Text object on {0}.", typeof(FreeResponseQuizPanel).ToString())); } else { AnswerText.text = answerString; } if (ShowAnswerContainer) { ObjectHelper.SetObjectActive(ShowAnswerContainer, true); } }