Skip to content

Commit

Permalink
fix: Fixing ClientScene UnregisterPrefab (#1815)
Browse files Browse the repository at this point in the history
* adding error if prefab is null

* fixing prefab not being removed
  • Loading branch information
James-Frowen committed Apr 30, 2020
1 parent 66728cd commit 9270765
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Assets/Mirror/Runtime/ClientScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,24 @@ public static void RegisterPrefab(GameObject prefab, SpawnHandlerDelegate spawnH
/// <param name="prefab">The prefab to be removed from registration.</param>
public static void UnregisterPrefab(GameObject prefab)
{
if (prefab == null)
{
logger.LogError("Could not unregister prefab because it was null");
return;
}

NetworkIdentity identity = prefab.GetComponent<NetworkIdentity>();
if (identity == null)
{
logger.LogError("Could not unregister '" + prefab.name + "' since it contains no NetworkIdentity component");
return;
}
spawnHandlers.Remove(identity.assetId);
unspawnHandlers.Remove(identity.assetId);

Guid assetId = identity.assetId;

prefabs.Remove(assetId);
spawnHandlers.Remove(assetId);
unspawnHandlers.Remove(assetId);
}

/// <summary>
Expand Down

0 comments on commit 9270765

Please sign in to comment.