Dedicated Server / MPPM is not stripping script roles before Awake() in Editor

Just as the title say when running in the editor DS / MPPM is stripping scripts only after awake is called. In a build they appear to be properly stripped out.

This is a relatively large problem when trying to test anything in the editor as the state of the scene may be different than in a build. It also leads to annoying errors being spammed for scripts that should have been stripped.

Simple replication is

  1. Create a Unity 6 project
  2. Add the MPPM / DS package
  3. Write a small script that prints a message on Awake.
  4. Set the script to client only via inspector or project settings.
  5. Run the editor as server.
  6. See that awake is called regardless of script’s role

My use case and the reason for making this report is that I have components that validate themselves and objects that instantiate in Awake, but if that script is “client only” this leads to validation errors/warnings and “floating” / “broken” objects in the server’s scene.

I do understand that this may be a limitation of testing in the Unity Editor, but I at the very least want to ensure that is on the radar and (preferably) warned as a known bug somewhere for when others run into this.

This sounds remarkably like a bug I logged before, where I had a server build and a client run in editor, the client being launched after build & run. Yet the client would then run server code. it was closed cited fixed in 6000.0.20, and I seem to recall checking it had been. Havent been looking at this in a while.

Unfortunately jra is linking the bug as https://issuetracker.unity3d.com/product/unity/issues/guid/DSER-3 which is basically a page saying haha moved. So I cant see what the final tracking of the bug proper was

I was actually under the impression that this is just how it works. I made sure not to reference anything server-side during Awake and went with it.

From what I recall this seemed to be on purpose in the editor because there’s no “build” process when you enter playmode, and stripping anything before you entered playmode would dirty the scene and thus permanently remove those components. At least that’s my understanding here.

1 Like

You are probably right that this is due to there not being a build process in the editor.

I think this “quirk” needs to be mentioned or warned about in the documentation / editor.