BasicNetManager.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using UnityEngine;
  2. /*
  3. Documentation: https://mirror-networking.gitbook.io/docs/components/network-manager
  4. API Reference: https://mirror-networking.com/docs/api/Mirror.NetworkManager.html
  5. */
  6. namespace Mirror.Examples.Basic
  7. {
  8. [AddComponentMenu("")]
  9. public class BasicNetManager : NetworkManager
  10. {
  11. /// <summary>
  12. /// Called on the server when a client adds a new player with NetworkClient.AddPlayer.
  13. /// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
  14. /// </summary>
  15. /// <param name="conn">Connection from client.</param>
  16. public override void OnServerAddPlayer(NetworkConnectionToClient conn)
  17. {
  18. base.OnServerAddPlayer(conn);
  19. Player.ResetPlayerNumbers();
  20. }
  21. /// <summary>
  22. /// Called on the server when a client disconnects.
  23. /// <para>This is called on the Server when a Client disconnects from the Server. Use an override to decide what should happen when a disconnection is detected.</para>
  24. /// </summary>
  25. /// <param name="conn">Connection from client.</param>
  26. public override void OnServerDisconnect(NetworkConnectionToClient conn)
  27. {
  28. base.OnServerDisconnect(conn);
  29. Player.ResetPlayerNumbers();
  30. }
  31. }
  32. }