Using the VortexRuntime API in Unity Scripts
To use Vortex in a Unity application, an API is provided with the Vortex Integration Package for Unity. To install it in a Unity project, read this guide: Installing the Vortex Studio Package in a Unity Project.
When the package is properly installed, the API is available as a C# class called VortexRuntime under the Vortex namespace. It grants access to Vortex functions from the standard Vortex Integration and provides some additional validation and utilities.
Tip: the ulong data type is used as a pointer (or handle) to Vortex objects that are loaded. For instance, you can use LoadMechanism to load a particular mechanism file and then use its handle to get or set data. Don't forget to unload it!
VortexRuntime Class
VortexRuntime Method | Description |
---|---|
Simulation Helpers | |
| Creates the Vortex application. You can specify an optional VortexSettings argument, which is a simple class that defines some settings such as the Vortex Setup Document (vxc) that will be used during simulation. |
| Updates the Vortex application. |
| Destroys the Vortex application. |
| Resets the simulation time to 0. |
| Changes the application mode (editing, simulating, playback). |
| Starts the simulation. |
| Steps the application only once and pauses. |
| Stops the simulation. |
| Pauses the simulation. |
| Returns if the simulation is currently paused. |
| Returns the current frame since the simulation started. |
| Returns the simulation framerate. |
| Returns the current simulation time. |
| Returns the time step between the each simulation frame. |
Content Helpers | |
| Loads a Vortex mechanism from a file path at the specified position and orientation. |
| Unloads the specified mechanism. |
| Loads a Vortex scene from a file path. |
| Unloads the specified scene. |
| Looks for and returns the child object of another object, using its name. |
| From an object handle, returns the parent transform of this object as reference arguments. |
Others | |
| Returns the command line arguments set to the application. |
| Checks if the Vortex license is valid. |
| Checks if the the Vortex application is created. Also initializes the Vortex Runtime if it was not already. (Note: this is not a method, but a property) |
Furthermore, these next methods can be used to get or set data from and to Vortex, respectively.
Method | Description |
---|---|
Accessing Data from Vortex to Unity | |
| Returns the boolean value of a particular VHL interface's output field from the specified Vortex object. |
| Returns the integer value of a particular VHL interface's output field from the specified Vortex object. |
| Returns the real value of a particular VHL interface's output field from the specified Vortex object. |
| Returns the string value of a particular VHL interface's output field from the specified Vortex object. |
| Returns the vector2 values of a particular VHL interface's output field from the specified Vortex object. |
| Returns the vector3 values of a particular VHL interface's output field from the specified Vortex object. |
| Returns the vector4 values of a particular VHL interface's output field from the specified Vortex object. |
| Returns the position and rotation values of a particular VHL interface's output field from the specified Vortex object. PositionRotation is a simple class that regroups transform data (position, rotation, scale). |
| (Advanced) For a specified Vortex graphics node object, returns its data in a struct. See GraphicNodeData from Vortex.Types namespace. |
| (Advanced) From a specified Vortex object, returns an array of handles to graphics nodes in this object. |
Sending Data from Unity to Vortex | |
| Sets the boolean value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the integer value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the real value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the string value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the vector2 value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the vector3 value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the vector4 value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the Matrix4x4 value of a particular VHL interface's input field from the specified Vortex object. |
| Sets the extension pointer value of a particular VHL interface's input field from the specified Vortex object. The extensions pointer is also a handle of type ulong. |
Vortex Unity Components
Some Unity components were made to work in tandem with VortexRuntime, and provide an easy way to load Vortex content in Unity. Here they are:
VortexMechanism: Can be used to load a Vortex mechanism (vxmechanism) by specifying the file path to the component. Its object handle can then be accessed from code any time.
VortexScene: Can be used to load a Vortex scene (vxscene) by specifying the file path to the component. Its object handle can then be accessed from code any time.