This guide explains how to set up a Unity 6 project for use on a fulldome, using the repositories in the i-DAT organization.
This guide has been tested on Unity 6000.1.6f1.
- Create a blank Unity project. The
Universal 3Dtemplate is recommended. - Go to
Edit > Project Settings > Playerand set the following options:Other Settings > API Compatibility Levelset to.NET FrameworkResolution and Presentation > Fullscreen Modeset toWindowedResolution and Presentation > Default Screen Width / Heightset to a square, eg2048x2048
- Create a
Scriptsfolder.
-
Add the fulldome camera repository to the
Scripts/folder.This can be achieved by opening the
Scripts/folder in a command prompt and runninggit clone https://github.com/i-DAT/unity-fulldome-camera. Alternatively, download the source code from Github throughCode > Download ZIP, extract it, and place contents intoScripts/. -
Navigate into
Scripts/unity-fulldome-camera/Runtime. Add theFisheyeCamscript to your main camera, and drag theFisheyeshader into the shader field of the script. -
Disabe
Rendering > Post Processingon the camera component.
-
Add the NDI repository to the
Scriptsfolder using the same method as above. -
Navigate into
Scripts/KlakNDI. It is important to remove theHDRP,URP, andLegacyfolders as they will cause compilation errors. -
Navigate into
jp.keijiro.klak.ndi/Runtime/Component. Add theNdiSenderscript to your main camera and ensure thatCapture methodis set toGame View.The Unity game view should now appear in NDI receiver programs as
<host nane> (Game View). For testing, the DistroAV OBS plugin can be used to view NDI streams on a host computer. -
You may need to enter play mode once to ensure that NDI is running.
-
Add the OSC repositorepository to the
Scriptsfolder using the same method as above. -
Install the sensor app on a device to send OSC data to Unity.
-
Create or modify a script for your player controller. It must implement the
IOscClientinterface.When an OSC message is received from a client, a method is invoked with the name of the OSC address. If this is not found, a default method is called.
Here is an example client implementation:
using System.Collections.Concurrent; using System.Net; public class Player : MonoBehaviour, IOscClient { // Required to implement the interface, only useful for sending OSC packets back to the client. public IPEndPoint EndPoint { get; set; } public ConcurrentQueue<OscPacket> SendQueue { get; set; } Vector3 angle; // Set the player rotation to the phone rotation each frame. void Update() => transform.eulerAngles = angle; // Called each time an OSC message with the `/rotation` address is sent from the phone. public void rotation(float x, float y, float z) => angle = new Vector3(x, y, z) * Mathf.Rad2Deg; // Required to implement the interface. public void OnMessage(OscMessage m) => Debug.Log($"Unhandled OSC message {m}!"); }
-
Create a new script (such as
Manager) and add it to an object in your scene (such as a newEmptyor to the main camera). It must store anOscManagerobject and create new client objects when a phone connects.Its important to call the
manager.Update()each frame and callmanager.Disposewhen the object dies.Here is an example client manager implementation:
public class Manager : MonoBehaviour { OscManager manager = new(); void Start() { // Set the `OnConnect` callback to create a client each time a phone connects. manager.OnConnect = (endpoint) => { var player = new Player(); // Only necessary for sending OSC packets back to the client. player.Endpoint = endpoint; player.SendQueue = manager.sendQueue; return player; }; // Start the manager to listen for OSC messages. manager.Start(); } void Update() => manager.Update(); void OnDestroy() => manager.Dispose(); }
More complete demos can be found in unity-fulldome-multiplayer-demo and flight-simulator.