Unity-Technologies/UnityCsReference · error · NotSupportedException

Check the connected players list instead

Error message

Check the connected players list instead

What it means

Thrown unconditionally by EditorConnectionInternal.IsConnected(). The method is intentionally a stub that always throws NotSupportedException with the message 'Check the connected players list instead' — the single-boolean IsConnected model was retired in favor of enumerating connected players (PlayerConnection.GetPlayers / the connected-player list), which distinguishes per-player state. There is no input that makes it succeed.

Source

Thrown at Editor/Mono/EditorConnectionInternal.bindings.cs:68

        void IPlayerEditorConnectionNative.UnregisterInternal(Guid messageId)
        {
            UnregisterInternal(messageId.ToString("N"));
        }

        void IPlayerEditorConnectionNative.Initialize()
        {
            Initialize();
        }

        void IPlayerEditorConnectionNative.DisconnectAll()
        {
            DisconnectAll();
        }

        public bool IsConnected()
        {
            throw new NotSupportedException("Check the connected players list instead");
        }

        [NativeConditional("ENABLE_PLAYERCONNECTION && UNITY_EDITOR")]
        [FreeFunction("EditorConnectionManaged::Get")]
        public extern static void Initialize();

        public static void UnregisterInternal(string messageId)
        {
            UnregisterInternal(new GUID(messageId));
        }

        [NativeConditional("ENABLE_PLAYERCONNECTION && UNITY_EDITOR")]
        [StaticAccessor("EditorConnectionManaged::Get()", StaticAccessorType.Dot)]
        [NativeName("Unregister")]
        private extern static void UnregisterInternal(UnityEngine.GUID messageId);

        public static void RegisterInternal(string messageId) { RegisterInternal(new GUID(messageId)); }

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Replace the boolean check with the connected-player enumeration API and test for a non-empty list.
  2. Search the codebase for IsConnected() usages and remove/replace each — there is no way to make this call succeed.
  3. If a boolean is needed, wrap: bool anyConnected = PlayerConnection.GetPlayers().Count > 0;

Example fix

// before
if (connection.IsConnected()) { connection.Send(kMsg, data); }
// after
var players = PlayerConnection.GetPlayers();
if (players.Count > 0) { connection.Send(kMsg, data, players[0].playerId); }
Defensive patterns

Strategy: fallback

Validate before calling

// IsConnected() always throws; use the player list instead.
bool anyConnected = PlayerConnection.GetPlayers()?.Count > 0;

Prevention

When it happens

Trigger: Any call to EditorConnection.IsConnected() (or the PlayerConnection surface that delegates to it). It cannot return normally, so the throw is deterministic, not conditional.

Common situations: Porting older tutorial/sample code that checks IsConnected before sending; an API surface that exposes IsConnected for back-compat but is no longer backed.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/9b93127e075904a4. Report an issue: GitHub.