Quick Start

You can test the Video SDK in a Unity scene right away, without writing a single line of code, thanks to the ready-to-use components it includes. Just follow the steps below. To learn more about each component, check out the Video Components page.

Preparation

  • Create a new Unity project (Unity 6000.0 LTS is the minimum supported version). We recommend selecting either the Universal 2D or Universal 3D Unity template, which use the Universal Render Pipeline (URP).
  • Download and install the package as described on the SDK & Download page.
  • Although it is compatible with Fusion & Quantum, please note that you don't need to download or install either of them, as the Video SDK includes a transport initialization component that handles the connection.

Photon Connection

  • Create a PhotonConnection game object in the scene and add a StreamTransportClient component to it (alternatively, when using Fusion, a properly configured FusionVoiceClient works too)
  • Configure the Photon Video App Id (How to Obtain Your AppId)
    • Configure its Transport Client Settings \ App Id with a Photon Video App Id.
StreamTransportClient component
StreamTransportClient component
  • The Photon App Id can also be managed centrally and reused across multiple scenes. To do so, enable the Use Shared App Settings option, then click the Shared App Settings button
StreamTransportClient VoiceAppSettings
StreamTransportClient VoiceAppSettings
Centralized VoiceAppSettings
Centralized VoiceAppSettings

Sender

  • Create a Sender game object in the scene and add a CameraStreamSender component on it.
CameraStreamSender component
CameraStreamSender component

Receiver

  • Create a Receiver game object in the scene and add a VideoStreamReceiver component on it.
VideoStreamReceiver component
VideoStreamReceiver component

Display

  • Add a UI panel to the scene. It will automatically create a canvas root object.
  • Add a GridLayoutGroup component to the panel game object and change the Cell Size parameter to 400/400
Grid Layout component
Grid Layout component
  • Add a PreviewVideoScreenViewHandler component on the panel game object
    • Set the panel in the Screens parent field
PreviewVideoScreenViewHandler component
PreviewVideoScreenViewHandler component
  • Add a RemotePlayersVideoScreenViewHandler component on the panel game object
    • Set the panel in the Screens parent field
RemotePlayersVideoScreenViewHandler component
RemotePlayersVideoScreenViewHandler component

Run

  • Press Play in the Unity editor to start streaming
  • You should see your local camera preview
Camera Local Preview
Camera Local Preview

Audio

Now that we've verified that the video is working, we can add the audio stream:

  • Create an AudioTransmission game object in the scene and add the AudioStreamSender & AudioStreamReceiver components.
AudioTransmission game object
AudioTransmission game object

For more advanced audio use cases, please check demo scenes 3 and 7, which use the FusionVoiceClient and UnityVoiceClient components respectively.

Testing Two-Camera Streaming on a Single Computer

If you want to test video streaming between two clients on a single computer, it can be achieved with the following steps:

  • First, make sure you have two cameras available on your computer (the embedded camera plus an external USB camera, for example).
  • On the CameraStreamSender component, set the Webcam Selection parameter to Webcam Index, and set the Webcam Index parameter to 0
Webcam Selection With Webcam Index 0
Webcam Selection With Webcam Index 0
  • Open the Build profiles, make sure the current scene is selected, and create a build
  • Launch the application to check that you can see the first camera stream
  • Now you can either create a second build with the Webcam Index parameter set to 1, or simply change the value and press Play in the Unity editor.
Webcam Selection With Webcam Index 1
Webcam Selection With Webcam Index 1

Demo Scenes

Several demo scenes are also available in the /Assets/Photon/PhotonVoice/Demos/DemoVideoUnityComponents/Scenes folder to illustrate different use cases of the Video SDK, such as:

  • displaying video on Quad Renderer
  • integration with Fusion
  • using custom textures on the sender
  • applying a shader before sending
  • using the Voice SDK UserData field
  • integration with the Unity Voice client
  • camera selection and control

For each demo scene, don't forget to configure the Photon Video App Id on the StreamTransportClient component or to use the UseVoiceAppSetting option.

Back to top