Parsec Unity by IronWarrior - 6

SDK

Unity wrapper for Parsec SDK C# bindings to allow hosting and joining Parsec sessions within a Unity app.

Unity 2019.4.10f1Unknown LicenseUpdated 20 days agoCreated on September 12th, 2020
Go to source

⚠️ This project is a work-in-progress and is not production ready ⚠️

This repository uses the Parsec C# SDK to allow hosting and joining Parsec sessions within Unity. The Parsec C# SDK provides interoperability with the native Parsec SDK. Parsec is an interactive video streaming application that is commonly used to play local multiplayer games over a network. This allows a developer to add networked multiplayer to their project without needing to write any netcode. This repository is not affiliated with the Parsec team.

Screenshot of both local and remote views of the demo game

Demo video

Getting Started

This repository does not contain the Parsec SDK libraries. You will need to copy the following into this repo from the Parsec SDK:

You can also run the setup scripts for the Unity SDK (described on this page) to have these libraries set up in the Unity examples included in the Parsec SDK, and then copy them from there into this repository.

Unity does not allow a single project to be open in multiple Editor instances. This can be frustrating when working with networked projects, as it would require a build to be created each time you wish to test both host and client. A workaround to this is to use the Unity Project Junction tool included with this repository to create a second dummy project.

To start a host and connect a client, you will need a Parsec account (created on their website) and a valid sessionId and peerId retrieved using the Parsec API (the examples do come included with a valid session/peerId at the time of writing, but this may change. Better to request your own).

Examples

Run the scene Assets/ParsecUnity/Experiments/ParsecTest to get started. The status will be displayed on screen if the connection is successful. Tick the Try Make Texture toggle on the client to start polling for video frames.

If you have successfully run the above scene, you can try the demo project in Assets/Demo/Main. This uses the Unity Input System to handle input. Note that in the Editor, to allow guest inputs to be correctly read on the host, you’ll need to lock input in the host Editor instance (Window > Analysis > Input Debugger > Options > Lock Input to Game View).

TODO

  • Unity sometimes crashes when attempting to connect a client. Unknown why.
  • Parsec supports many different color formats for streaming. Currently FORMAT_I420 is the only supported one in this package (not sure how to force the host to use a specific format to test the others). The color in the guest view is also slightly off right now.
  • ~Audio is not currently supported. The Parsec Unity SDK does have an example that supports outgoing audio from a single AudioSource. Currently the exception MarshalDirectiveException: [MarshalAs] attribute required to marshal arrays to managed code. is thrown when calling Parsec.ClientPollAudio.~ This is fixed on the audio branch. However, it uses an edited version of the ParsecUnity dll, which is not included in this package. This branch will be merged when the fix propogates to the official distribution of the ParsecUnity dll.
  • Unity Input System is the only supported input on both the host and client. The Parsec Unity SDK does have input for both the legacy input and Rewired, so adding in more input systems should not be challenging.
  • …and lots more! Search for // TODO in the comments.
Show all projects by IronWarrior