Configuring and using Viewport Cameras

In the Vortex Unity integration, Vortex Viewports are supported automatically. This means that for any viewport defined in a 3D Display extension from a Vortex Setup document (.vxc), the viewport will be added correctly at runtime in Unity.

In the 3D Display extension, the Viewport Name must match a name of a Camera Viewpoint extension from a scene or mechanism. Other camera extensions are not currently supported in the Vortex integration for Unity.

3D Display defining the “Center“ viewport in the default setup document for Unity Editor.

This works either in the Unity Editor or in a built Unity application.

Viewport Game Object and Components

When a scene is loaded at runtime, a game object is added to the scene for each Viewport. In a distributed simulator, the object is only added if the viewport is present on the application’s current simulator node.

This game object has the Camera component, as well as the Vortex Viewport component. All data on these components is defined automatically based on the 3D Display extension properties.

“Center“ Viewport Game Object and its components, in Unity Editor Play mode

Configuring the Camera

It is possible to overwrite the default viewport camera at the scene level. This can be done easily by defining a prefab from a Game Object containing the Camera component.

This prefab must be set on the Vortex Scene component from the Vortex scene’s game object, in the Viewport Camera Prefab field, as seen here:

When a Viewport game object is added in this scene at runtime, it will then use this camera instead of the default one.

Accessing the Viewport Camera from script

It is sometimes useful to access a Viewport camera from a script’s C# code. This can be done using this simple static method from the VortexViewport class:

static public Camera VortexViewport.GetViewportCamera(string viewportName)

Example:

Camera cam = VortexViewport.GetViewportCamera("Center"); if (cam != null) { Debug.Log($"Current camera field of view: {cam.fieldOfView}"); }

Note that the camera is not available directly when the scene is loaded, but shortly after, once it was added by the integration.

Â