기술 자료

Multiplayer Play Mode integration

Understand how Unity Multiplayer Play Mode scenarios use local or remote Cloud Code servers to test multiplayer behavior.
읽는 시간 4분최근 업데이트: 4일 전

Unity Cloud Code integrates with Unity Multiplayer Play Mode scenarios so you can test multiplayer behavior while calling Cloud Code modules from multiple Unity Editor instances. The scenario controller selects a local or remote server, prepares it before Play mode, and routes supported instances to that server.
The server target affects how the scenario prepares Cloud Code and which instance types use the local server. The main and additional Editor instances follow the scenario's target, while Local Instances require separate configuration to call a local server. Module changes aren't deployed while Play mode is running. When you exit Play mode, the running local server reloads changed modules.
참고
This integration requires Unity 6.7 or later.

Understand scenario configuration

In the Play Mode Scenarios window, each scenario's Additional Configuration section contains the Cloud Code settings. Deploy to Cloud Code determines whether the controller only validates the setup or also prepares Cloud Code. Deploy Target selects Local or Remote.
Before starting a run, the controller checks that the project has a Unity Gaming Services project link and a selected environment. For a local target, it also checks that the server port is available and that any running local server uses the configured port. The scenario shows a warning if a Local Instance uses a release build profile, because release builds ignore the local-debugging argument.
For a local target, the scenario starts the local Cloud Code server. The server remains running after the scenario ends. The controller stops it when you select another scenario, run the scenario with Deploy Target set to Remote, or quit the Editor. For a remote target, the scenario deploys only changed modules. The scenario then waits after the last upload completes before the instances run, giving the Cloud Code invokers time to download the updated code.
The integration deploys Cloud Code C# modules only, not Cloud Code JavaScript scripts, for both local and remote targets. The scenario starts the local server before Play mode, so the selected local target is available when the instances run. In the standard Editor workflow outside a scenario, Unity determines whether calls go to a local or remote server when you enter Play mode. Calls go to the local server if it's running, and to the remote service if it's not.
For more information about testing with the Cloud Code and Multiplayer Play Mode integration, refer to Multiplayer testing workflow.

Understand instance routing

The main Editor and additional Editor instances use the same server selected by Deploy Target. The scenario sends the server endpoint to those Editors before Play mode starts. You can change Deploy Target between runs without restarting the instances.
Local Instances run player builds, which the scenario can't redirect. To call a local server, a Local Instance needs the
--cloud-code-local-debugger
argument. If the server uses a non-default port, specify it as
--cloud-code-local-debugger=<port>
. The instance also needs a build profile with Development Build enabled. The scenario warns when either requirement is missing. Other instance types always call the remote service.

Understand local deployment and server state

The Console window lists modules changed during Play mode, and the local server reloads them after you exit Play mode. The Active Scenario window displays the Cloud Code server status. Its Cloud Code Server section has controls to stop the local server and clear its data. The window disables these controls while Play mode is running.
Local scoped data persists after you restart the server or redeploy a module. Clearing the local server state removes data from all scopes.
참고
You don't need Multiplayer Play Mode to use a local Cloud Code server. When you start the server from the Cloud Code toolbar button and enter Play mode in the Unity Editor, the Editor sends server calls to the local server if it's running, and to the remote service if it isn't.
If your project uses Multiplayer Play Mode, scenarios add to this behavior. While the active scenario has Deploy to Cloud Code enabled, the scenario controls the server instead of the toolbar, and the toolbar shows that a Play Mode scenario controls the server. When you enter Play mode, the scenario starts the local server or deploys to the remote service, depending on Deploy Target, and directs the main Editor and every additional Editor instance to that server. When the active scenario doesn't deploy Cloud Code, the toolbar controls the local server as usual.

Additional resources