[Server] attribute race condition above OnStartServer, on NetworkAuthenticator.
Describe the bug [Server] attribute above OnStartServer, on NetworkAuthenticator stops it being called.
[IMPORTANT] How can we reproduce the issue, step by step: Create a public class CustomNetworkAuthenticator : NetworkAuthenticator Script template version is ideal. Add [Server] above OnStartServer. You get a yellow warning "[Server] function 'System.Void CustomNetworkAuthenticator::OnStartServer()' called when server was not active"
[Server]
public override void OnStartServer()
{
Debug.Log("1 OnStartServer : " + gameObject.name);
// register a handler for the authentication request we expect from client
NetworkServer.RegisterHandler<AuthRequestMessage>(OnAuthRequestMessage, false);
}
FYI, none of the script templates show or say to add the Server tag, so shouldn't happen often to users. [Server] above OnStartServer in a custom NetworkManager works fine.
Good catch. This happens because the listening happens after the execution of OnStartServer.
https://github.com/vis2k/Mirror/blob/db50c39b918d42b21eb9d0b24319e8ca75f30d19/Assets/Mirror/Runtime/NetworkManager.cs#L244-L263
Closing per comments above...tag should not be added.