using RiptideNetworking;
using RiptideNetworking.Utils;
using UnityEngine;
public class NetworkManager : MonoBehaviour
{
private static NetworkManager _singleton;
private static NetworkManager Singleton
{
get => _singleton;
private set
{
if (_singleton == null)
_singleton = value;
else if (_singleton != value)
{
Debug.Log($"{nameof(NetworkManager)} instance already exists, destroying duplicate!");
Destroy(value);
}
}
}
public Server Server { get; private set; }
[SerializeField] private ushort port;
[SerializeField] private ushort maxClientCount;
private void Awake()
{
Singleton = this;
}
private void Start()
{
RiptideLogger.Initialize(Debug.Log, Debug.Log, Debug.LogWarning, Debug.LogError, false);
Server = new Server();
Server.Start(port.maxClientCount);
}
private void FixedUpdate()
{
Server.Tick();
}
private void OnApplicationQuit()
{
Server.Stop();
}
}
It said I'm wrong on this line: private set
Here is the problem: The accessibility modifier of the 'NetworkManager.Singleton.set' accessor must be more restrictive than the property or indexer 'NetworkManager.Singleton'
Please tell me how to fix this?
CodePudding user response:
You should remove the "private" on the set accessor, because the property is already private.
ref: accessor must be more restrictive than the property or indexer