为什么我的 Unity3d Unet 生成不起作用

Why does my Unity3d Unet spawning not work

我正在测试 Unet,现在 运行 在远程客户端上生成时遇到问题。 Server/Client 侧的所有作品。

我生成了三个非玩家对象:"Orange"、Apple" 和 "Banana"。在我进行测试时,我使用非常基本的代码来执行此操作。但是,生成时,仅生成了两个对象,第三个出现以下错误:

Failed to spawn server object, assetId=3bd88da3adcb74d04addd82122b34fee netId=6 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

我一直在努力寻找解决方案,但这是我收到的唯一信息。我使用以下生成代码:

using UnityEngine;
using System.Collections;
using UnityEngine.Networking;

public class SpawnManager : NetworkBehaviour {

[SerializeField] GameObject Spawn1;
[SerializeField] GameObject Spawn2;
[SerializeField] GameObject Spawn3;
[SerializeField] GameObject Spawn4;

public override void OnStartServer() {
    SpawnFruits ();
}

void SpawnFruits() {

    GameObject goX = Resources.Load ("Apple") as GameObject;
    GameObject goY = Resources.Load ("Orange") as GameObject;
    GameObject goZ = Resources.Load ("Banana") as GameObject;

    GameObject go1 = GameObject.Instantiate (goX, Spawn3.transform.position, Quaternion.identity) as GameObject;
    NetworkServer.Spawn (go1);
    GameObject go2 = GameObject.Instantiate (goY, Spawn4.transform.position, Quaternion.identity) as GameObject;
    NetworkServer.Spawn (go2);
    GameObject go3 = GameObject.Instantiate (goZ, Spawn1.transform.position, Quaternion.identity) as GameObject;
    NetworkServer.Spawn (go3);


}
}

好吧,我又来了! ...我在对象的注册码中有错字。我在代码中进行非玩家注册。