Skip to content

Unity SCORM Integration Tutorial

armontoya edited this page Feb 21, 2012 · 12 revisions

By following the outlined steps below, you will be able to take the sample Unity project, MineSweep 3D, and easily convert it into a SCORM compliant application. Prior to beginning, it is assumed that you have installed Unity 3D 3.5 or higher with MonoDevelop, and that you have some experience with its GUI Editor, and have downloaded and unzipped the Unity SCORM Integration toolkit.

  1. Download and unzip the Minesweep 3D demo application into the folder where you extracted or cloned scorm4unity.
  2. Navigate to the folder MineSweep 3D\Assets and open up the scene called demoscene.
  3. Right-click under the Project tab, and select Import Package/Custom Package. Navigate to where you have unzipped the Unity SCORM Integration Toolkit and select the package file ScormIntegrationKit.
  4. After importing the SCORM Integration Toolkit, you should see a new menu item marked SCORM on the main menu bar. Click on this item and select "Create Scorm Manager" from the dropdown list.
  5. Parent all items in the Hierarchy to the SCORM manager. This is easily done by dragging them onto the listing for ScormManager in the Hierarchy.
  6. Open up the GameManager.cs script file, which is a component of the GameManager object. This should open up in MonoDevelop.
  7. Add the following members to the GameManager class:
private bool m_bInitialized;
private bool m_bCommitted;
  1. Provide the following functions to the GameManager:
public bool Initialized()
{
	return m_bInitialized;
}

public bool Committed()
{
	return m_bCommitted;
}

void Scorm_Initialize_Complete()
{
	m_bInitialized = true;
}

void Scorm_Commit_Complete()
{
	m_bCommitted = true;
}
  1. In the MenuState script class, modify the conditional in the OnGUI function to account for SCORM activation: From
if (m_bActiveState)
{
	m_kRectWindow = GUI.Window(0,m_kRectWindow,ProcessWindow,"Scenario Complete");
}

to

if (m_bActiveState && GameManager.Instance.Committed())
{
	m_kRectWindow = GUI.Window(0,m_kRectWindow,ProcessWindow,"Scenario Complete");
}
  1. For our simple SCORM setup, we just want to know whether the user disabled all the mines successfully or not (e.g. pass/fail). Thus, when the round is complete, we must notify the ScormManager of our success or failure through a simple call to SetSatisfaction, which describes whether the primary objective was satisfied or not:
public override void OnStateEntered()
{
   //...snip...

   if (MineDisarmHandler.Instance.GetActiveMineCount() > 0)
   {
	m_sScenarioState = "Player Detonated Mine";
	m_kRectScenarioState = new Rect(130, 120, 140, 20);
        ScormManager.SetSatisfaction(Scorm2004.successStatusType.failed); //You 'sploded yourself :-(
   }
   else
   {
	m_sScenarioState = "Player Removed All Mines";
	m_kRectScenarioState = new Rect(120, 120, 160, 20);
	ScormManager.SetSatisfaction(Scorm2004.successStatusType.passed); //You prevented all the 'splosions :-)
   }

Finally, we need to tell the ScormManager that the user completed the course and then say there's nothing more to record so it can send your data to an LMS, LRS, etc.:

ScormManager.SetCompletionStatus(Scorm2004.completionStatusType.complete); //Satisfied or not, we're still done
ScormManager.Commit(); //No going back now.

Clone this wiki locally