|
14 | 14 | #endif |
15 | 15 | using UnityEngine.SceneManagement; |
16 | 16 | using Debug = UnityEngine.Debug; |
| 17 | +using Unity.NetCode; |
17 | 18 |
|
18 | 19 |
|
19 | 20 | namespace Unity.Netcode |
@@ -1342,6 +1343,22 @@ private System.Collections.IEnumerator WaitForHybridPrefabRegistration(StartType |
1342 | 1343 | } |
1343 | 1344 | } |
1344 | 1345 | } |
| 1346 | + |
| 1347 | + private bool UnifiedIsConfiguredCorrectly() |
| 1348 | + { |
| 1349 | + if (NetCodeConfig.Global == null) |
| 1350 | + { |
| 1351 | + Debug.LogError($"[{nameof(NetworkManager)}][Unified] You must create a {nameof(NetCodeConfig)} and set it to a single world in order to run in hybrid mode!"); |
| 1352 | + return false; |
| 1353 | + } |
| 1354 | + if (NetCodeConfig.Global.HostWorldModeSelection != NetCodeConfig.HostWorldMode.SingleWorld) |
| 1355 | + { |
| 1356 | + Debug.LogError($"[{nameof(NetworkManager)}][Unified] You must configure {nameof(NetCodeConfig)} to only use a single world in order to run in hybrid mode!"); |
| 1357 | + return false; |
| 1358 | + } |
| 1359 | + return true; |
| 1360 | + } |
| 1361 | + |
1345 | 1362 | #endif |
1346 | 1363 |
|
1347 | 1364 | /// <summary> |
@@ -1372,6 +1389,13 @@ public bool StartServer() |
1372 | 1389 | // TODO-UNIFIED: Review and align on this being a way to handle knowing if the world should be created. |
1373 | 1390 | if (NetworkConfig.Prefabs.HasGhostPrefabs) |
1374 | 1391 | { |
| 1392 | + if (!UnifiedIsConfiguredCorrectly()) |
| 1393 | + { |
| 1394 | + m_ShuttingDown = true; |
| 1395 | + ShutdownInternal(); |
| 1396 | + return false; |
| 1397 | + } |
| 1398 | + NetCodeConfig.Global.HostWorldModeSelection = NetCodeConfig.HostWorldMode.SingleWorld; |
1375 | 1399 | DefaultWorldInitialization.Initialize("Default World", false); |
1376 | 1400 | StartCoroutine(WaitForHybridPrefabRegistration(StartType.Server)); |
1377 | 1401 | return true; |
@@ -1440,6 +1464,13 @@ public bool StartClient() |
1440 | 1464 | // TODO-UNIFIED: Review and align on this being a way to handle knowing if the world should be created. |
1441 | 1465 | if (NetworkConfig.Prefabs.HasGhostPrefabs) |
1442 | 1466 | { |
| 1467 | + if (!UnifiedIsConfiguredCorrectly()) |
| 1468 | + { |
| 1469 | + m_ShuttingDown = true; |
| 1470 | + ShutdownInternal(); |
| 1471 | + return false; |
| 1472 | + } |
| 1473 | + |
1443 | 1474 | DefaultWorldInitialization.Initialize("Default World", false); |
1444 | 1475 | StartCoroutine(WaitForHybridPrefabRegistration(StartType.Client)); |
1445 | 1476 | // TODO-UNIFIED: Need a way to signal everything completed. |
@@ -1508,6 +1539,13 @@ public bool StartHost() |
1508 | 1539 | // TODO-UNIFIED: Review and align on this being a way to handle knowing if the world should be created. |
1509 | 1540 | if (NetworkConfig.Prefabs.HasGhostPrefabs) |
1510 | 1541 | { |
| 1542 | + if (!UnifiedIsConfiguredCorrectly()) |
| 1543 | + { |
| 1544 | + m_ShuttingDown = true; |
| 1545 | + ShutdownInternal(); |
| 1546 | + return false; |
| 1547 | + } |
| 1548 | + |
1511 | 1549 | DefaultWorldInitialization.Initialize("Default World", false); |
1512 | 1550 | StartCoroutine(WaitForHybridPrefabRegistration(StartType.Host)); |
1513 | 1551 | // TODO-UNIFIED: Need a way to signal everything completed. |
|
0 commit comments