Skip to main content
Version: Dev (main)

Unity

QAROS ships two Unity packages that stream a Unity scene to AR/VR devices. They carry the C# binding, not the native runtime: the Editor and every player load the runtime of the QAROS installed on the PC, like any other source app.

PackageFolderInstall whenDepends on
com.quaternar.streamingQarStreamingAlwaysUnity Input System 1.7.0, Unity UI 1.0.0
com.quaternar.streaming.mrtkQarStreamingMRTKOnly in MRTK 3 projectscom.quaternar.streaming, Unity Input System 1.7.0, XR Core Utils 2.2.3, MRTK Core 4.0.0-pre.1, MRTK Input 4.0.0-pre.1, MRTK UX Components 4.0.0-pre.1, MRTK Extended Assets 3.0.3
  • QarStreaming is the integration: the QarStreaming and QarDevice prefabs, stereo camera capture for the built-in render pipeline and URP, a sample scene and the C# binding in lib/windows-x64.
  • QarStreamingMRTK extends it, never replaces it: an MRTK XR rig prefab, MRTK profile and configuration assets, QAROS hands as an MRTK hand subsystem, the QAROS head pose driving the XROrigin, and an MRTK sample scene.

Requirements​

  • Unity 2022.3 or newer. Tested with 2022.3 and 6000.4.
  • Windows x64. The QAROS runtime is built for Windows x64 only.
  • Direct3D 11 or Vulkan. In Project Settings > Player > Other Settings, turn off Auto Graphics API for Windows and put Direct3D11 or Vulkan first in the list. Direct3D 12 and OpenGL are not supported. See Graphics APIs for how the two differ.
  • The built-in render pipeline or URP.
  • QAROS installed on the PC, release or demo (see Installation). The app loads its runtime, joins its Hub and streams to the target apps in its session. Without it, joining fails with "QAROS Hub is not installed on this PC", in the Inspector and the in-game target list; in the Editor a dialog also offers to open the installation guide.

Installation​

The Unity ZIP (QAROS Unity <version>.zip, see Installation) holds both packages, ready to install, plus a short INSTALL.md and the CHANGELOG.md.

  1. Unzip it to a location you keep. A package added from disk is referenced, not copied: moving or deleting the folder breaks the project.
  2. MRTK 3 projects only: install the MRTK packages first (see MRTK 3).
  3. Add the packages in this order. Unity cannot resolve QarStreamingMRTK's dependency on a local package by itself, so the base package must already be there.
    1. QarStreaming/package.json
    2. QarStreamingMRTK/package.json, only if the project uses MRTK 3

With the Package Manager​

  1. Open your Unity project.
  2. Open Window > Package Manager.
  3. Press + and choose Add package from disk....
  4. Select the package's package.json.

With the manifest file​

Alternatively, add the packages to the project's Packages/manifest.json. The paths are relative to that file. With the unzipped folder next to the Unity project:

{
"dependencies": {
"com.quaternar.streaming": "file:../../QAROS-Unity-<version>/QarStreaming",
"com.quaternar.streaming.mrtk": "file:../../QAROS-Unity-<version>/QarStreamingMRTK"
}
}

Release and demo​

One QAROS Unity <version>.zip serves both flavors: the packages load whichever QAROS is installed on the PC, release or demo. Switching flavors means installing the other QAROS, not changing the packages.

The sample scene​

Open QarSampleScene from the QarStreaming package's Samples folder. It has one QarStreaming prefab and a Connect button that calls QarMultiUserStreamingBehaviour.Join.

  1. Start QAROS on this machine, and a target: a headset player, or a Visualizer receiver.
  2. Enter Play mode. The app joins the Hub on this PC as a local app; the first time, click Allow in the QAROS approval prompt.
  3. The scene streams to every reachable target. The target list shows in the game view and in the QarStreaming Inspector.

Prefabs​

PrefabRoleContains
QarStreamingThe streaming coordinator, one per sceneQarMultiUserStreamingBehaviour (onboarding, which targets to stream to, render and gesture settings, the device prefab, and runtime settings such as EnableMixer) and QarTargetPickerOverlay (the in-game target list)
QarDeviceOne target's viewQarDeviceBehaviour, a left-eye and a right-eye camera, and optional hand and head visualizers

QarMultiUserStreamingBehaviour creates a child QarDevice for each target it streams to, named after the target, and destroys it when streaming to that target stops.

Onboarding​

The app joins the Hub's session once; every target is streamed to through that session. The general flow is in Onboarding and Sessions; in Unity it is driven by Onboarding on QarMultiUserStreamingBehaviour.

The app joins the Hub on this PC as a local app, with no code. The first time, QAROS asks the user to allow the app (the Unity Editor once for every project opened in it); later starts join silently. Nothing is saved, so every start joins the same way.

  • An app QAROS launched joins the same way.
  • On a PC whose Hub joined another PC's Hub as a member, the app joins its own PC's Hub the same way and lands in the primary's session.
  • To shut the app out, revoke its approval in QAROS.
SettingUse
Approval Timeout SecondsHow long to wait for the user to allow the app. 0 uses the Hub's default (120 s).
Use Unity Graphics AdapterCreates the session's GPU devices on the adapter Unity renders with (NVIDIA only), so frames need no copy between GPUs. QAR_GPU_ADAPTER_ID in the environment overrides it (see Choosing the GPU).
Timeout SecondsHow long to wait for the session after the approval.

Join() blocks until the Hub answers. When it fails, LastJoinError says why and the target list offers to join again.

Targets​

A target is a target app already in the Hub's session: a HoloLens 2, Meta Quest or Metalens player, the Android streamer, or a Visualizer receiver. The app never invites or starts a device. A target appears in the list once it joined the Hub on its own (see Player Installation to Device), and leaves it when it is gone.

  • Stream To All Targets (on by default) streams to every reachable target, including ones that join later.
  • Turn it off to pick: only the targets checked in the list are streamed to.
  • Each row shows the target's display name, its device type and its state; hover it for the peer ID.
  • The list is in the game view (QarTargetPickerOverlay, immediate-mode GUI, no Canvas needed) and in the QarStreaming Inspector in Play mode. Turn the overlay's Visible off, or remove it, to build your own UI on the API below.
  • A target that fails to connect is tried again every few seconds while it stays picked.
MemberDoes
Join(), IsJoined, LastJoinErrorJoins the Hub and starts listing targets; whether it did; why not
TargetsThe target list (QarStreamTarget: Id, DisplayName, Category, DeviceId, DeviceFamily, DeviceName, DeviceLabel, Presence, IsOnline, IsReachable, Selected, Device, ConnectionState, LastError)
TargetsChangedRaised on the main thread when a target joins, leaves, changes or is picked
StreamToAllTargetsStream to every reachable target, or only the picked ones
SetTargetSelected(PeerId, bool), IsStreamedTo(target)Picks a target; whether it is streamed to
Leave()Stops streaming to every target and stops listing them

App volume​

Every target shows the scene in one app volume, identified by App Volume Common Name (the product name when empty), so all users see the same scene placed once. Joining again gets the same volume back with its placement.

Gestures​

Enable Gestures turns QAROS app volume gestures on or off for the targets' hands. Keep it on for normal QAROS gesture handling. Turn it off when another input stack consumes the hands.

GUI panels and served panels​

The components wrap streaming only. For GUI panels, including pages your app serves itself, use the C# API on the session the components joined:

using Quaternar.Qaros;
using QuaternarStreaming;

Session session = QarSession.Current; // null until a QAROS component has joined the hub
var bundle = session.PanelContent.PublishDirectory("ui", Application.streamingAssetsPath + "/panels");
  • QarSession.Current is the one session of the process; never dispose it, the components own it.
  • session.GuiPanels creates and changes panels (GuiPanelOptions.ServedContent for a served page), session.PanelContent publishes the files and carries the page's messages. Both work as described in Custom GUI Panels.
  • Put panel pages under StreamingAssets so a player build ships them as plain files.

Naming a panel​

There is no panel component, so a panel's name is set in code, not in the Inspector. The display name is the label the mixer shows above the panel; the common name is its stable identity.

var options = new GuiPanelOptions("inspector.myapp.example.com") // stable identity, ASCII
{
DisplayName = "🎬 Inspector", // label shown above the panel, emoji allowed
};
GuiPanelId panelId = session.GuiPanels.GetOrCreate(options).ValueOrThrow();

Result<Unit> renamed = session.GuiPanels.ChangeDisplayName(panelId, "Settings");
if (renamed.Info.StatusCode == StatusCode.GuiPanelDisplayNameInvalid)
Debug.LogWarning("Panel name refused: " + renamed.Info.Message);
  • The name follows the display name rules: one line of at most 64 characters, counted as Unicode code points, not C# chars (one emoji is two chars but one character).
  • Line breaks, other control characters and bidirectional formatting characters are refused with StatusCode.GuiPanelDisplayNameInvalid, both on create and on rename. A refused name is never shortened, and a refused rename keeps the previous name.
  • A C# string can hold a lone surrogate (half of an emoji), which has no UTF-8 form. It reaches QAROS as U+FFFD (�) and is accepted, so cut a name only at whole characters, for example with StringInfo.
  • Show the name in your own Unity UI from GuiPanel.DisplayName in the panel updates, never from the common name.

Coordinate spaces​

The views and hands a target's device receives are in its app volume's app content space, in OpenXR convention: right-handed, +Y up, -Z forward, in app units. The Unity world is the app content root.

  • QarDeviceBehaviour.ToUnityPosition, ToUnityRotation, ToUnityLinearVelocity and ToUnityAngularVelocity convert to Unity's left-handed space. They only flip handedness.
  • LeftHandJoints and RightHandJoints stay in app content space: convert them with those methods.
  • Never apply the app volume's pose or scale on top: the Unity world already is the app content space.

Transparency​

QarDeviceBehaviour declares what its color's alpha means with the stream, through Alpha Mode in the Inspector. The mixer composites the stream by it (Transparency).

Alpha ModeUse when
Premultiplied (default)The cameras clear to transparent black, so translucent materials, soft edges and glow are composited over what is behind the app volume
StraightYour color is not multiplied by its alpha (for example a custom pass writes straight alpha). QAROS premultiplies it before sending
OpaquePost-processing or a custom pass overwrites the alpha channel. With Premultiplied such content would turn transparent
UnspecifiedDeclares nothing: the mixer draws the stream opaque unless the operator enables alpha for undeclared streams
  • Unity's transparent materials write no depth. They show at the middle of the app volume along each view ray, so they occlude there and move without parallax.
  • Opaque materials must leave alpha at 1. A shader that writes a lower alpha on an opaque surface makes it translucent in the mixer.

MRTK 3​

QarStreamingMRTK puts QAROS behind MRTK 3: the QAROS head pose drives the MRTK rig and the QAROS hands become MRTK hands.

  • Install MRTK first with the Mixed Reality Feature Tool. The Unity Package Manager may not offer the MRTK versions the package needs.
  • It uses the first streamed target only. To keep a hand from being handled twice, by MRTK and by QAROS app volume gestures, it turns gestures off for that target's device at runtime. The Enable Gestures value in the Inspector does not change. Further targets stream as usual.
  • The MRTK sample scene QarSampleSceneMrtk has a debug Connect button built with MRTK UX Components and MRTK Extended Assets. The integration itself does not use those two packages; only that button does.

Player builds​

A player build carries no native runtime: like the Editor, it loads the runtime of the QAROS installed on the PC where it runs. Install QAROS there; do not copy a qar-streaming-c.dll next to the player, since a copy beside the binding would be loaded instead of the installed one. A player or Editor started with QAR_INSTANCE set (a QAROS development hub sets it for the apps it starts) loads the runtime of that instance instead, and fails to load when that instance has none; the lookup is the one in Authoring a Language Binding.

Graphics APIs​

The package streams under Direct3D 11 and under Vulkan, in the Editor and in player builds.

  • Any other graphics API is refused. Under Direct3D 12 or OpenGL the runtime does not start: it throws a NotSupportedException that names the API, and nothing streams.
  • Vulkan needs QarUnityGraphics.dll, which the package ships in lib/windows-x64. It is the one native plugin Unity loads itself, at startup, so that it can prepare Unity's Vulkan device for sharing frames. Keep Load on startup set in its import settings. Without it a Vulkan player cannot stream, and the runtime refuses to start with a NotSupportedException that says why.
  • Under Vulkan, cap the frame rate instead of using VSync. A Vulkan frame is shown only after Unity's render thread has handed it over. Show Vulkan Frames On Worker, on QarDevice and on by default, waits for that hand-off on a worker thread instead of the next frame.
    • In our measurements a Vulkan player capped at 60 fps with Application.targetFrameRate streamed at the Direct3D 11 rate, with frames within 2 ms as fresh.
    • Under VSync it streamed a little over half the Direct3D 11 rate (46 against 79 per second on a 165 Hz display), so set QualitySettings.vSyncCount to 0 and cap with targetFrameRate.
    • Turning the option off shows every frame from the main thread, which streams about half as many frames at a cap. Leave it on unless you need that fallback.
    • With the option on, the package can move the eye cameras, hands and headset model just before the first eye camera renders. A script reading them in LateUpdate may see the previous frame's pose.