mmorpg/Assets/Mirror/Examples/Basic/Scripts/BasicNetManager.cs
2024-08-23 16:17:24 +05:30

43 lines
1.5 KiB
C#
Executable File

using UnityEngine;
namespace Mirror.Examples.Basic
{
[AddComponentMenu("")]
public class BasicNetManager : NetworkManager
{
public static new BasicNetManager singleton { get; private set; }
/// <summary>
/// Runs on both Server and Client
/// Networking is NOT initialized when this fires
/// </summary>
public override void Awake()
{
base.Awake();
singleton = this;
}
/// <summary>
/// Called on the server when a client adds a new player with NetworkClient.AddPlayer.
/// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerAddPlayer(NetworkConnectionToClient conn)
{
base.OnServerAddPlayer(conn);
Player.ResetPlayerNumbers();
}
/// <summary>
/// Called on the server when a client disconnects.
/// <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>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerDisconnect(NetworkConnectionToClient conn)
{
base.OnServerDisconnect(conn);
Player.ResetPlayerNumbers();
}
}
}