First Insert Action¶
Once you finished following the Step by step guide you are ready to start developing your first insert action with MAGES SDK.
Insert Action is referring to a specific type of Action that a user has to insert an object to a specific position in order to complete it.
There are two ways to create an insert action. One can either start writing the script themselves, or create it automatically by setting up the required parameters from the MAGES menu.
To create your first insert action, without writing any code, please follow the following steps:
Navigate to MAGES menu –> Action Editor –> Insert Action.
The following window will appear:
Each of the fields are explained below:
Path to store the action: This is the path where your prefabs will be saved. The automatically generated script will also be saved in the corresponding path under
Assets/MAGEScomp/Operation/ActionScripts/... (Please refer to Project File System for more information regarding the file system.).
The variables X, Y and Z in the path
LessonX/StageY/ActionZ/must correspond to the IDs of the current lesson, stage and action.
In case this is your first action, it is recommended that X == 0, Y == 0, Z == 1. The action stored in Lesson0/Stage0/Action0 is usually the operation start action, initializing the application, so practically your first action is the second one of the new operation.
Action Script Name: This is the name of the automatically generated script. It is recommended to name it “ActionNameAction” in which you can replace the “ActionName” part with the actual name of your action. This naming rule is recommended but not mandatory.
Interactable Prefab: This is an empty gameobject field. In this field, the prefab of your choice must be added. This is the prefab that you would like the user to pick up in order to place it somewhere.
Final Prefab: This is an empty gameobject field. In this field, the same prefab that you added in the Interactable Prefab field must be added, but now it should be located in the correct position and location. In other words, this will represent the target prefab in the final/correct position that the end-user must place it.
You can save this position/rotation on the final prefab through the Unity Editor. After having saved it, you can simply drag and drop it in the Final Prefab field.
Generate Default Box Collider: This is a checkbox. If it is enabled, a default box collider will be created for the Interactable Prefab.
Include Hologram: This is a checkbox. If it is enabled, a hologram will also be created/include in the action.
The hologram is a green see-through version of the Interactable Prefab, located in the position of the Final Prefab, indicating the correct position/rotation of the Interactable Prefab in order to aid the user.
To create a simple insert action, to act as the first action in your application (after the operation start action), kindly follow the next steps:
Locate and open the Empty_MAGES_Scene.unity scene.
From the Create Insert Action window, change the Path to store the action to
Set the Action Script Name to MyFirstInsertAction, or whichever name you prefer.
Create a 3D cube, through the Unity menu.
Drag and drop the reference of this cube to the Interactable Prefab and Final Prefab fields.
Click the Generate Interactable Prefab and Generate Final Prefab buttons.
Through the Unity Scene, move the newly spawned objects (namely New_Interactable_Prefab and New_Final_Placement_Prefab) to the position you desire. For this example, move the New_Interactable_Prefab to (-19, 1.5, -16) and the New_Final_Placement_Prefab to (-19, 1.5, -12).
The New_Interactable_Prefab prefab has gravity enabled by default. This will cause the cube to fall continuously in this example. It is recommended to click on the New_Interactable_Prefab and locate the RigidBody component in the Inspector. Then enable the Is Kinematic checkbox.
The New_Final_Placement_Prefab prefab is set to be destroyed by default during the end of the action. In order to prevent this from happening click on the New_Final_Placement_Prefab and locate the Interactable Final Placement Prefab Constructor component in the Inspector. Then change the Prefab Perform Action from Destroy to Remain.
Click the Save Interactable Prefab and Save Final Prefab buttons.
Make sure that the Include Hologram checkbox is checked.
Finally click the Generate Action Script button to create the script.
Your script will reside under
Your prefabs will reside under
Adding your new action to your application¶
Once the necessary prefabs and script have been generated, the only thing that remains for the action to be operational is to actually be included in your application.
The empty MAGES scene contains a dummy action (i.e. an action that is empty and does nothing, which follows after the operation start action). We will now swap this action with your newly created one.
From the MAGES menu click the Scenegraph Editor option.
A new window will open. From this window, click the File button and then Load.
Navigate to the following path
Assets\Samples\ORamaVR MAGES\4.0.0\Sample App\Resources\Storyboard\platformand open the file Empty_Scene.xml.
Once the xml loads, you will see a graph like this.
Locate the Dummy Action node and click on the script slot to change the script.
From the explorer window, locate the MyFirstInsertAction.cs script and click Open (normally it will be in MAGES/Operation/ActionScripts/Lesson0/Stage0/Action1).
Click the File button and then Save.
The script and the prefabs can always be created manually as well. In that case, kindly read the guide located here: Insert Action.
2DoF Controller Tutorial¶
The 2DoF controller is used to run a MAGES application in Desktop 3D mode, without the need of any HMD or controllers.
In this mode, the character is controlled through the keyboard and/or mouse/trackpad.
In Desktop 3D mode, the gameobject in the Unity hierarchy, which represents the camera is called 2DoFCamera.
A UI is available in this mode, by pressing the space bar. This will open the menu of 2DoF which gives the user the ability to move, rotate, lock the hands. Below, you can see the 2DoF menu on action.
In the following table, a detailed explanation can be found, regarding each button of the 2DoF Controller.
W or Up Arrow
S or Back Arrow
A or Left Arrow
D or Right Arrow
Toggle Body move mode
Toggle Right Hand move mode
Toggle Left Hand move mode
(Usually followed after pressing F1 or F2), enables the hand rotation mode with the use of mouse/trackpad
(Only after F1), enables/disables the cursor and freezes the camera rotation.
Left Mouse/Trackpad Click
Hand trigger on the hand targeted by F2/F3
Right Mouse/Trackpad Click
THand grip on the hand targeted by F2/F3
Switch hand plane movement (when F2 or F3 enabled)
Ctrl and Left Click or Right Click
Sends the Left or Right hand to the direction of the crosshair
You can utilize the Desktop 3D camera controller in order to run and execute the first insert action you created before. To do so, please follow the instructions below:
Ensure that the Empty_MAGES_Scene is open and click the “Play” button of the Unity Editor.
You will be presented with a menu like the following. This is the Operation Start menu.
There are two ways to continue in this point. Either by pointing one of the virtual hands to the Single Player button and clicking with the left mouse button, or by pressing the X button on the keyboard. It is recommended to continue with the latter for now.
In this point, the New_Interactable_Prefab you set up in the tutorial above, will be present in the scene along with a hologram.
Activate the virtual right hand in order to be able to pick up objects. To do so, press F2+Tab from the keyboard.
Move close to the cube using the W/A/S/D/E/Q buttons. You will know that you are in the correct position when an outline appears around the cube like in the image below.
Click using the left mouse button (or trackpad) and hold it. The right virtual hand will hold the cube, as long as you hold the button.
In case you accidentally drop the cube, you can restart the action by moving to the next one with the X button and then to the previous one again with the Z button.
While holding the left mouse button, use the W/A/S/D/E/Q keys again to move next to the green hologram.
Try to align the cube with the hologram, using the W/A/S/D/E/Q buttons. Once you do this correctly, the cube will be inserted in the position specified by the hologram.
Building the application¶
This section will demonstrate how to create an executable with your newly created insert action (in this case for the Windows platform.)
Copy the Empty_Scene.xml file, which is located under
Assets\Samples\ORamaVR MAGES\4.0.0\Sample App\Resources\Storyboard\platform, to
If this path does not exist in your Documents folder, create it manually.
Through Unity menu, navigate to File –> Build Settings.
Make sure that the Empty_MAGES_Scene is present in the list of scenes in Build Settings. If not, simply add it by click the Add Open Scenes button.
Click the Build button and specify the directory where you would like the executable file to be created.
Once the building procedure is finished, navigate to the directory you specified in step 4, and double click on the executable to start the application.
For more information regarding building an application with MAGES™ SDK and all the supported platforms, please visit Build Instructions.