Unity Dedicated Server package

The com.unity.dedicated-server experimental package is designed to help developers create and optimize dedicated server builds more efficiently.

The first feature brought by this package is Content selection, which allows you to select which content should go on either the client or the server.

This feature can be used at different stages of the authoring experience, including at the project level, per game objects or per components. It also works with prefabs and addressables.

8916265--1221187--Client.gif
Client version of a project

8916265--1221190--Server.gif
Server version of a project

Requirements

  • Editor version 2023.1+
  • From Unity Hub, Install the Dedicated Server Build Support module for the platform you’re targeting.
  • From the package manager, install com.unity.dedicated-server. As this package is experimental, it needs to be installed by name.

Getting started

To get up and running follow the steps in the package documentation

Current state

This package is currently experimental and is subject to change. It is not yet suitable for production.

What's next

The dedicated-server package will evolve to add more tools to facilitate creating and optimizing a dedicated game server. It will also evolve based on the feedback we will receive. To get a sneak peek at the roadmap or to request a feature, please visit this page.

Feedback

We would love to hear your feedback!

  • Do you have any use cases that we haven’t covered yet?
  • Are there any workflows that are unclear or missing?
  • Do you have any issues or questions about the documentation?

Please share your thoughts in this forum or on the discord - #Dedicated-server-platform-development.

How to report bugs

Ideally, we'd like any bugs reported through the built-in bug reporter tool, as that will automatically provide us with some relevant context. When reporting bugs:

  • Please attach a bare-bones project that reproduces the issue to help us diagnose the issue you’re facing with the dedicated server platform or with the dedicated-server package.
  • If available, please also attach some log files.

Have a look at this page for more information and best practices around bug reporting.

Once you have submitted a bug report through the bug reporter, please feel free to start a discussion about it in this sub-forum.

Resources

Related to the creation of a dedicated server platform in the Unity editor

Related to hosting and operating a dedicated server in the cloud

Thank you for your interest, we're looking forward to your feedback!

4 Likes


So....no backporting any improvements to 2021 / 2022 LTS?

Sorry, but we're allergic to alpha / beta versions.

Thanks for this feedback.
Although it is not supported officially, we made the package partially compatible with 2022.
This include the content selection feature that is presented above.
Official backport down to 2022 LTS is under consideration, the feedback we are currently gathering is going to help us determine if this makes sense or not.

We are using Unity in production, and speaking from experience of the last 2 Unity LTS versions, after 1 year of LTS a version becomes sufficiently bug free enough to be considered production ready.
This means for projects that are serious features from 2023.1 will be available for production use in mid 2025.
If the package is generally able to support 2022 it would be very nice to add support for it.
Not stripping content from Addressables is a big oversight given that Addressables is the go to content solution for bigger projects.
Currently I have to fork the SBP and put hacks in there to strip at least textures and audio files for servers but we are still a few gigabytes too heavy in the servers which lead to slow iteration times when testing server versions and queue times for players when waiting for new server instances spinning up.


Yes, we have been working on enabling the Addressables case. The first step was to allow Asset Bundles to be built for the Dedicated Server subtarget so it can be optimized.

You will find that the Content Selection feature provided in this package allows you to decide to remove specific components from your prefabs. So, for instance, you can check the "Strip all rendering components" option which is going to remove all Camera, Light and Renderer components from your Dedicated Server bundles.

That is great to hear.
To clarify, is 2022.1 also able to handle the package or only .2/LTS?


It could work. We develop currently for 2023.x, keeping it --for now, unofficially-- compatibility with 2022.2 as much as we can (some features can be missed). Compatibility with other versions would be entirely incidental.

1 Like

Are there licensing requirements that prevent us from shipping against pre-release software? I'm just curious, because if there are then when does this software come out of pre-release?

As far as I know there is none. The experimental / pre-release tags mean that the package is in active development. As such, the API might change between the current version and the released one.

We do not have a release date yet but we regularly publish updates on our discord.

The docs aren't clear how to exclude a prefab...seems the buttons are missing?

This is a prefab of a UI fragment:
9554314--1350376--upload_2023-12-30_10-41-41.png

And here is a regular prefab:
9554314--1350382--upload_2023-12-30_10-42-23.png

Compared to a scene object that has buttons under the Layer dropdown:
9554314--1350421--upload_2023-12-30_12-27-23.png

If I just select the prefab in the project, the buttons are there, but disabled:
9554314--1350424--upload_2023-12-30_12-32-42.png

Unity and Package version:
9554314--1350391--upload_2023-12-30_10-44-54.png

@MrG , thanks for bringing this up.

The root game object of a prefab asset cannot be excluded, doing so, that's why the buttons are disabled/hidden for those objects.
When you add a prefab to a scene, then it becomes a prefab instance and its root game object can now be excluded if desired.

As an alternative you could try to exclude the component in charge of instantiating that prefab.

Please update the documentation accordingly in the Prefab Assets and Instances section.

This is a networked object, so typically there would be a lot of child art, animations, etc. that the server shouldn't have, and generally such are spawned at runtime, not in a scene.

Suggestions, other than what I'm doing now, which is making a base prefab for the server and a variant for the client?


Sure! I'll make sure we improve it.


This is a valid and possible case today. The root Game Object cannot be stripped, but all its child objects and components --such as renderers, animations, textures-- can actually be removed.


In general it wouldn't be necessary to create prefab variants. You can have one single prefab and mark all renderers/audio/animations as "Client only", Unity would take care of stripping them accordingly when you build to the Dedicated Server target.

1 Like

@cristianm_unity Could there be a setting for shutting off the physics engine in server builds? I know we can disable simulation at the project level, but some games like card / arcade / UI games don't need physics on server, while clients still need raycast and such.

Im not getting the dedicated server (or not) buttons in the inspector, any ideas? (2023.3b5) with dedicated server pre-2


Try looking at Project Settings > Multiplayer > Multiplayer Roles (see the manual)


That's an interesting case! No, we don't have an option to override the physics simulation settings specifically for server.
But this is something I think you should be able to do with a script using the OnPreprocessBuild. There you can detect which target you're building to and then override the physics (and any other settings).

Ah, I missed that - ok, shame that didnt work the way i expected which was sure, when i built my server it did indeed strip things, but then in the ide, it still strips those things so its not as easy to just hit play and play as a client.. hmm

@bugfinders , I'm not sure I understand. Do you say that you expect that when you are playing in the editor you want things to be stripped in the same way as when you build the server?

If that's the case, it actually works that way. You'll see a new option in the top bar so you can decide if you want to enter play mode as a client, server or client+server.

9627719--1367567--upload_2024-2-6_13-45-37.png

im having a seriously stupid day arent I?

to be fair it is a very small button barely bigger than some checkboxes, but yes i missed that too what i havent missed is

public class PostBuild : IPostprocessBuildWithReport
{
    public int callbackOrder { get; }
    public void OnPostprocessBuild(BuildReport report)
    {
        UnityEditor.EditorApplication.EnterPlaymode();
    }
}

while it runs the code in the IDE it runs it as the server despite selecting client.. cos ctrl+P sure runs it as client, but that does not. Infact because on build it changes that button to server, and so even ctrl+P to run runs as server until i change it again, whether its set on client, both... build sets it to server..