Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public ulong GetConfig(bool cache = true)
writer.WriteUInt16Packed(ProtocolVersion);
writer.WriteString(MLAPIConstants.MLAPI_PROTOCOL_VERSION);

if (!AllowRuntimeSceneChanges)
if (EnableSceneManagement && !AllowRuntimeSceneChanges)
{
for (int i = 0; i < RegisteredScenes.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ void DelayedSpawnAction(Stream continuationStream)
}
}

SpawnManager.CleanDiffedSceneObjects();

NetworkingManager.Singleton.IsConnectedClient = true;

NetworkingManager.Singleton.InvokeOnClientConnectedCallback(NetworkingManager.Singleton.LocalClientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ internal Stream GetStream()
/// <param name="value">The object to write</param>
public void WriteObjectPacked(object value)
{
if (value == null || value.GetType().IsNullable())
// Check unitys custom null checks
bool isNull = value == null || (value is UnityEngine.Object && ((UnityEngine.Object)value) == null);
Comment thread
mattwalsh-unity marked this conversation as resolved.

if (isNull || value.GetType().IsNullable())
{
WriteBool(value == null);
WriteBool(isNull);

if (value == null)
if (isNull)
{
return;
}
Expand Down
19 changes: 19 additions & 0 deletions com.unity.multiplayer.mlapi/Runtime/Spawning/SpawnManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,25 @@ internal static void DestroySceneObjects()
}
}

internal static void CleanDiffedSceneObjects()
{
// Clean up the diffed scene objects. I.E scene objects that have been destroyed
if (pendingSoftSyncObjects.Count > 0)
{
List<NetworkedObject> objectsToDestroy = new List<NetworkedObject>();

foreach (KeyValuePair<ulong, NetworkedObject> pair in pendingSoftSyncObjects)
{
objectsToDestroy.Add(pair.Value);
}

for (int i = 0; i < objectsToDestroy.Count; i++)
{
MonoBehaviour.Destroy(objectsToDestroy[i].gameObject);
}
}
}

internal static void ServerSpawnSceneObjectsOnStartSweep()
{
NetworkedObject[] networkedObjects = MonoBehaviour.FindObjectsOfType<NetworkedObject>();
Expand Down