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();
}
}
上面说我在这条线上错了:私人套装
问题是:“NetworkManager.Singleton.set”访问器的可访问性修饰符必须比属性或索引器“NetworkManager.Singleton”更具限制性。
请告诉我怎么解决这个问题?
发布于 2022-08-06 11:06:54
您应该删除set访问器上的“私有”,因为该属性已经是私有的。
参考文献:accessor must be more restrictive than the property or indexer
https://stackoverflow.com/questions/73259179
复制相似问题