Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.14k stars 434 forks source link

Multiplayer Playmode: fails to load MonoBehaviour scripts located in a embedded package #2989

Open CodeSmile-0000011110110111 opened 2 months ago

CodeSmile-0000011110110111 commented 2 months ago

Description

MonoBehaviour components located in an embedded package are non-functional (not loaded, not running), and appear as "(Script)" in virtual player inspectors:

image

These components are not loaded and won't do anything. A log in Awake() does not appear in the console of the virtual player (log appears in main editor).

This leaves all MonoBehaviour that are in embedded packages broken and unusable within virtual players!

The above components are located in a package in /Packages/de.codesmile.netcode/Runtime/Components/.. The TEst component was originally under /Assets where it worked fine but after moving it into the same package folder as NetworkEventLogger it stopped working too.

The packages-lock.json seems to have been updated correctly, with the package type changing from 'embedded' to 'local':

      "version": "file:de.codesmile.netcode",
      "depth": 0,
      "source": "embedded",
      "version": "file:../../../../Packages/de.codesmile.netcode",
      "depth": 0,
      "source": "local",

I have closed the project, deleted the entire Library folder, and tried again with the same result. There were no console messages when activating the virtual player or entering playmode.

Reproduce Steps

Create a local package under /Packages/package-name Create a MonoBehaviour script with a Debug.Log in Awake() Add the script to a GameObject in the scene Activate a virtual player Enter playmode in that scene Check the virtual player's Inspector for "(Script)"

Move the script to Assets to see that this fixes the issue.

Environment

Notes: I also downgraded to MPPM 1.0.0, deleted Library, and had the same issue.

CodeSmile-0000011110110111 commented 2 months ago

Reported with test case as:
CASE IN-81312