You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f19e6ef
Browse filesBrowse the repository at this point in the historyBrowse files
fix: reject spawning a hybrid instance in a session without hybrid prefabs
Only prefab registration rejected hybrid prefabs. An unregistered hybrid prefab instance, for
example one spawned through a prefab handler, spawned into a session that never entered hybrid
mode and ran its ghost spawn, ownership and bridge code without a unified world. The spawn
authority now logs an error and refuses the spawn.
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -368,6 +368,7 @@ public bool Contains(NetworkPrefab prefab)
368
368
#if UNIFIED_NETCODE
369
369
internalconststringDistributedAuthorityHybridPrefabError="Distributed authority does not support hybrid prefabs.";
370
370
internalconststringHybridPrefabAfterStartError="Hybrid prefabs must be registered before the NetworkManager starts.";
371
+
internalconststringHybridSpawnWithoutHybridPrefabsError="Hybrid prefab instances can only be spawned in a session that started with a hybrid prefab registered.";
NetworkLog.LogError($"{NetworkPrefabs.HybridSpawnWithoutHybridPrefabsError}{networkObject.name} was not spawned.");
1181
+
}
1182
+
returnfalse;
1183
+
}
1184
+
#endif
1185
+
1174
1186
if(playerObject&&networkObject.InScenePlaced)
1175
1187
{
1176
1188
NetworkLog.LogError(newContext(LogLevel.Developer,"Player prefab is marked as belonging to a scene. This may cause issues.").AddNetworkObject(networkObject).AddInfo("SceneName",networkObject.SceneOrigin.name));
/// Validates the hybrid prefab registrations that are rejected:<br />
15
15
/// - Any hybrid prefab in a distributed authority session. The start fails, and one added during the session is not registered.<br />
16
16
/// - A hybrid prefab added during a session that started without hybrid prefabs. It is not registered.<br />
17
+
/// - A hybrid prefab instance spawned during a session that started without hybrid prefabs. It is not spawned.<br />
17
18
/// - A hybrid player prefab counts toward hybrid mode before the session starts, so distributed authority rejects it.<br />
18
19
/// - A NetworkPrefab override with a hybrid source or target prefab, in any topology. The entry is ignored.<br />
19
20
/// </summary>
@@ -152,6 +153,29 @@ public IEnumerator HybridPrefabAddedAfterStartIsRejected()
152
153
Assert.IsTrue(prefabs.Contains(m_HybridPrefab),"The hybrid prefab was rejected after the session ended!");
153
154
}
154
155
156
+
/// <summary>
157
+
/// Validates that an unregistered hybrid prefab instance, for example one spawned through a prefab handler, is not spawned in a session that started without hybrid prefabs.
0 commit comments