你好,所以我用这个视频制作了一个简单的网络https://unity3d.com/learn/tutorials/topics/multiplayer-networking/merry-fragmas-30-multiplayer-fps-foundation
我在预制件上保存了网络身份并放入游戏管理器
但是我尝试连接作为客户端,是的我有一个正在运行的主机,但我作为客户端连接我得到这个
找不到1的Spawn场景对象 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
答案 0 :(得分:0)
您尚未在网络管理器下注册任何“Spawnable prefabs” - >产卵信息
放置你想要在那里产生的预制件,你就可以在网络上产生它。
答案 1 :(得分:0)
一旦项目发展,您可能会在场景中拥有数十个需要注册的NetworkIdenties,很容易错过一些,这是常见的“找不到Spawn场景对象”错误的原因之一。
我编写了此编辑器脚本,以检查是否没有向NetworkManager注册任何SceneObjects。将其添加到编辑器文件夹,然后使用“工具”菜单运行它。
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEditor;
public class CheckUNETSceneRegistered : ScriptableObject {
const string menuName = "UNET SceneObjects Registration Check";
[MenuItem("Tools/Check UNET SceneObjects are Registered")]
static void DoCheck()
{
NetworkManager networkManager = FindObjectOfType<NetworkManager>();
if(networkManager == null)
{
EditorUtility.DisplayDialog(menuName, "No NetworkManager found", "OK", "");
return;
}
List<string> registeredPrefabNames = new List<string>(networkManager.spawnPrefabs.Count);
foreach (GameObject g in networkManager.spawnPrefabs)
registeredPrefabNames.Add(g.name);
int i = 0;
foreach (NetworkIdentity uv in FindObjectsOfType<NetworkIdentity>())
{
if (!registeredPrefabNames.Contains(PrefabUtility.GetPrefabParent(uv.gameObject).name))
{
Debug.LogError("Found " + uv.name + " in the scene, but its prefab " + PrefabUtility.GetPrefabParent(uv.gameObject).name + " was not registered");
i++;
}
}
EditorUtility.DisplayDialog(menuName, ( i>0 ? "Found " + i + " unregistered Scene Objects. See Logs." : "All OK" ), "OK", "");
}
}