C# Unity网络:当客户端首先加载场景时,网络对象不会出现在客户端上
我的多人游戏中的对象实例化有问题。游戏布局很简单:玩家进入一个大厅,一旦每个人都标记就绪,就会进行倒计时,C# Unity网络:当客户端首先加载场景时,网络对象不会出现在客户端上,c#,unity3d,client-server,unity-networking,unity3d-unet,C#,Unity3d,Client Server,Unity Networking,Unity3d Unet,我的多人游戏中的对象实例化有问题。游戏布局很简单:玩家进入一个大厅,一旦每个人都标记就绪,就会进行倒计时,LobbyManager调用ServerChangeScene(游戏场景)来加载游戏级别。问题是,在很多负载上,所有网络对象都没有在客户机上实例化。经过一点游戏测试后,我注意到只有当客户端在服务器之前加载场景时,才会发生这种情况-当服务器首先加载时,所有内容都正确显示,并且游戏按它应该的方式玩。有没有办法确保服务器先加载 一些代码供参考: public override void OnLo
LobbyManager
调用ServerChangeScene(游戏场景)
来加载游戏级别。问题是,在很多负载上,所有网络对象都没有在客户机上实例化。经过一点游戏测试后,我注意到只有当客户端
在服务器之前加载场景时,才会发生这种情况-当服务器
首先加载时,所有内容都正确显示,并且游戏按它应该的方式玩。有没有办法确保服务器先加载
一些代码供参考:
public override void OnLobbyServerPlayersReady()
{
currentNumberTeam1 = 0;
currentNumberTeam2 = 0;
StartCoroutine(ServerCountdownCoroutine());
}
public IEnumerator ServerCountdownCoroutine()
{
float remainingTime = _matchStartCountdown;
int floorTime = Mathf.FloorToInt(remainingTime);
while (remainingTime > 0)
{
yield return null;
remainingTime -= Time.deltaTime;
int newFloorTime = Mathf.FloorToInt(remainingTime);
if (newFloorTime != floorTime)
{
floorTime = newFloorTime;
for (int i = 0; i < lobbySlots.Length; ++i)
{
if (lobbySlots[i] != null)
{
(lobbySlots[i] as CharacterSelect).RpcUpdateCountdown(floorTime);
}
}
}
}
for (int i = 0; i < lobbySlots.Length; ++i)
{
if (lobbySlots[i] != null)
{
(lobbySlots[i] as CharacterSelect).RpcUpdateCountdown(0);
}
}
ServerChangeScene(playScene);
}
public override void onLobbyServerPlayerReady()
{
CurrentNumberTemp1=0;
CurrentNumberTemp2=0;
start例程(ServerCountdownCoroutine());
}
公共IEnumerator服务器CountDownCorroutine()
{
浮动剩余时间=\u匹配开始计数;
int floorTime=Mathf.floorTime(剩余时间);
同时(剩余时间>0)
{
收益返回空;
剩余时间-=Time.deltaTime;
int newFloorTime=Mathf.floortime(剩余时间);
if(newFloorTime!=floorTime)
{
floorTime=新的floorTime;
对于(int i=0;i