/// <summary> /// The add objective button pressed. /// </summary> /// <remarks>Validates the input GUI elements are not empty, then adds a new objective to SCORM and the GUI</remarks> public void ButtonAddObjectivePressed() { GameObject inputFieldObjectiveId = GameObject.Find("InputFieldObjectiveId"); GameObject inputFieldObjectiveDescription = GameObject.Find("InputFieldObjectiveDescription"); string objectiveId = inputFieldObjectiveId.GetComponent <InputField> ().text; string objectiveDescription = inputFieldObjectiveDescription.GetComponent <InputField> ().text; if (objectiveId == "" | objectiveDescription == "") // Validate the Input Elements { if (objectiveId == "") { inputFieldObjectiveId.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter an ID!"; } if (objectiveDescription == "") { inputFieldObjectiveDescription.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "You must enter a description!"; } } else // Add the Objective { StudentRecord.Objectives newObjective = new StudentRecord.Objectives(); newObjective.id = objectiveId; newObjective.description = objectiveDescription; StudentRecord.LearnerScore score = new StudentRecord.LearnerScore(); score.min = 0f; score.max = 100f; score.raw = 0f; score.scaled = 0f; newObjective.score = score; newObjective.successStatus = StudentRecord.SuccessStatusType.unknown; newObjective.completionStatus = StudentRecord.CompletionStatusType.not_attempted; newObjective.progressMeasure = 0f; ScormManager.AddObjective(newObjective); int index = ScormManager.GetObjectives().Count; AddObjectiveToList(index, newObjective); //Reset Fields inputFieldObjectiveId.GetComponent <InputField> ().text = ""; inputFieldObjectiveDescription.GetComponent <InputField> ().text = ""; inputFieldObjectiveId.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "Objective ID..."; inputFieldObjectiveDescription.transform.Find("Placeholder").gameObject.GetComponent <Text> ().text = "Objective Description..."; } }