Skip to content

Commit

Permalink
Fix reconnections. This allows the main scene to be reloaded without
Browse files Browse the repository at this point in the history
causing errors.
  • Loading branch information
John Detter committed Oct 16, 2024
1 parent f1b8fa8 commit 4d7f23c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/SpacetimeDBNetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ namespace SpacetimeDB
// Attach this to a gameobject in your scene to use SpacetimeDB.
public class SpacetimeDBNetworkManager : MonoBehaviour
{
private static bool _alreadyInitialized;
private static SpacetimeDBNetworkManager _instance;

public void Awake()
{
// Ensure that users don't create several SpacetimeDBNetworkManager instances.
// We're using a global (static) list of active connections and we don't want several instances to walk over it several times.
if (_alreadyInitialized)
if (_instance != null)
{
throw new InvalidOperationException("SpacetimeDBNetworkManager is a singleton and should only be attached once.");
}
else
{
_alreadyInitialized = true;
_instance = this;
}
}

Expand Down

0 comments on commit 4d7f23c

Please sign in to comment.