DarkRift
DarkRift copied to clipboard
Convert to Unity Package Manager (UPM) package
This draft illustrates how the repository could become a package compatible with Unity Package Manager.
This branch can be directly fed into Unity (more details on the Unity docs):
https://github.com/frarees/DarkRift.git#upm
Additionally, UPM packages can be:
- Packed and distributed (
.tgz
files added as releases in GitHub) using npm pack. - Uploaded to an npm registry such as OpenUPM (see Scoped Registries).
The current repository folder structure is not the only way to set up UPM package support. This structure favours ease of use and maintainability when UPM is the main distribution mechanism and Unity the main target.
This proposal makes DarkRift accessible for Unity developers across desktop platforms to contribute and navigate through DarkRift's code:
- No dependency on Visual Studio — tests have been rewritten to use UTF / NUnit. Makes life easier for Linux and macOS users.
- Code directly available from within Unity.
- Simplified development pipeline — don't have to develop and build outside of Unity.
Other benefits:
- Potential to write Play Mode and Edit Mode tests.
- Ability to include samples as part of the package.
- Seamless installation— this isn't just unpacking a compressed file into your Unity project, as it's the case with
.unitypackage
files. Unity handles package installation, removal and upgrading through the package manager window and APIs. - No clutter as part of end-users projects — files are not dropped in
Assets/
, but inPackages/
in read-only mode (unless you install the package for development, in which case you can modify it. Which is the intended setup for contributors). - Using Assembly Definitions — code is compiled to different dlls with different build parameters. End-users can also use asmdefs to define client/server logic within the same Unity project. Example based on the agar.io tutorial:
Note how client, server and common assemblies are defined in the same Unity project. The server DLL is discovered by the XmlUnityServer
without additional actions (compiled assemblies are located under Library/ScriptAssemblies
).


Downsides:
- No mocking support — Unity doesn't offer mocking as part of UTF out of the box. I didn't feel bundling Moq as part of DarkRift was worth either.
- Unity-centric setup. Compatibility with other engines is completely possible, but not as ergonomic to develop or build by default.
- The build artifact is no longer a set of DLLs, but a package with the source code. Creating DLLs is still possible as an additional build artifact.
TODOs:
- Not all tests are ported over.
- Console project not included.
- Sample content.
Feel free to list additional items I might have missed.
Note that Unity is planning to support first-class support for csproj files. Assembly Definitions will convert into csproj files and those will be consumed by Unity directly.