Skip to content

OnNetworkSpawn() is not called with specific enter play mode options enabled/disabled. #1879

@maxsroka

Description

@maxsroka

Description

OnNetworkSpawn() is not called on NetworkBehaviours under these circumstances:

  1. If Reload Scene and Reload Domain are disabled - OnNetworkSpawn will not be called just for the first time after scripts reload.
  2. If Reload Scene is disabled and Reload Domain is enabled - OnNetworkSpawn will not be called at all.

Reload Scene and Reload Domain are under the enter play mode settings in Projects Settings > Editor.

Reproduce Steps

  1. Add this script to a GameObject with a NetworkObject component:
using UnityEngine;
using Unity.Netcode;

public class Test : NetworkBehaviour
{
    public override void OnNetworkSpawn()
    {
        Debug.Log("OnNetworkSpawn() called");
    }
}
  1. Disable Reload Scene and/or Reload Domain in enter play mode settings.
  2. Enter play mode
  3. Start host

Actual Outcome

The message "OnNetworkSpawn() called" doesn't appear due to OnNetworkSpawn() not being called. If you disabled both Reload Scene and Reload Domain, the message will appear if you enter mode again without reloading scripts. If you disabled just the Reload Scene the message won't appear at all.

Expected Outcome

The message should appear in the console window.

Environment

  • OS: Windows 11
  • Unity Version: 2021.3.0f1
  • Netcode Version: 1.0.0-pre.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    stat:importedStatus - Issue is tracked internally at Unitytype:featureNew feature, request or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions