|
6 | 6 | using BlockId = System.UInt16; |
7 | 7 | using System.Runtime.CompilerServices; |
8 | 8 | using System.Threading.Tasks; |
| 9 | +using Mirror; |
9 | 10 | using UnityEngine.Profiling; |
10 | 11 | using UnityEngine.Rendering; |
11 | 12 | using Object = UnityEngine.Object; |
@@ -229,10 +230,25 @@ private void FullInstatiatePrefabsMainThread() { |
229 | 230 | continue; |
230 | 231 | } |
231 | 232 |
|
| 233 | + var isNetworked = false; |
232 | 234 | GameObject prefabDef = blockDefinition.definition.prefab; |
| 235 | + if (prefabDef.GetComponent<NetworkIdentity>()) isNetworked = true; |
| 236 | + |
| 237 | + // If client and networked prefab, do not spawn on client |
| 238 | + if ((!RunCore.IsServer() && isNetworked) && Application.isPlaying) { |
| 239 | + continue; |
| 240 | + } |
| 241 | + |
233 | 242 | var rotationBits = VoxelWorld.GetVoxelFlippedBits(voxelData); |
234 | 243 | var rot = VoxelWorld.FlipBitsToQuaternion(rotationBits); |
235 | | - GameObject prefab = GameObject.Instantiate(prefabDef, origin + localChunkPos, rot, obj.transform); |
| 244 | + |
| 245 | + var prefab = Object.Instantiate(prefabDef, origin + localChunkPos, rot, obj.transform); |
| 246 | + if (isNetworked && Application.isPlaying) { |
| 247 | + NetworkServer.Spawn(prefab); |
| 248 | + var networker = world.worldNetworker; |
| 249 | + // Probably need to signal to client to add this as well :s |
| 250 | + } |
| 251 | + |
236 | 252 | prefab.transform.parent = obj.transform; |
237 | 253 | prefab.transform.localScale = Vector3.one; |
238 | 254 |
|
|
0 commit comments