CreateNetworkedAndSpawn: reuse CreateNetworked

This commit is contained in:
vis2k 2021-05-20 11:35:57 +08:00
parent 86d8986f5b
commit 69fea4064b

View File

@ -84,10 +84,7 @@ protected void CreateNetworkedAndSpawn<T>(out GameObject go, out NetworkIdentity
Debug.Assert(NetworkClient.active, "NetworkClient needs to be active before spawning."); Debug.Assert(NetworkClient.active, "NetworkClient needs to be active before spawning.");
Debug.Assert(NetworkServer.active, "NetworkServer needs to be active before spawning."); Debug.Assert(NetworkServer.active, "NetworkServer needs to be active before spawning.");
go = new GameObject(); CreateNetworked(out go, out identity, out component);
identity = go.AddComponent<NetworkIdentity>();
component = go.AddComponent<T>();
instantiated.Add(go);
// host mode object needs a connection to server for commands to work // host mode object needs a connection to server for commands to work
identity.connectionToServer = NetworkClient.connection; identity.connectionToServer = NetworkClient.connection;