From bee3901a087cf8c0ce93c744327501de253331bf Mon Sep 17 00:00:00 2001 From: Simon Lemay Date: Tue, 26 Sep 2023 11:46:37 -0400 Subject: [PATCH] feat: Log errors when Relay/WebSocket settings are mismatched --- .../Runtime/Transports/UTP/UnityTransport.cs | 15 +++++++++++++++ .../Runtime/com.unity.netcode.runtime.asmdef | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs index 99682cb969..9e9f78efd4 100644 --- a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs +++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs @@ -1560,6 +1560,21 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver, } #endif +#if UTP_TRANSPORT_2_1_ABOVE + if (m_ProtocolType == ProtocolType.RelayUnityTransport) + { + if (m_UseWebSockets && m_RelayServerData.IsWebSocket == 0) + { + Debug.LogError("Transport is configured to use WebSockets, but Relay server data isn't. Be sure to use \"wss\" as the connection type when creating the server data (instead of \"dtls\" or \"udp\")."); + } + + if (!m_UseWebSockets && m_RelayServerData.IsWebSocket != 0) + { + Debug.LogError("Relay server data indicates usage of WebSockets, but \"Use WebSockets\" checkbox isn't checked under \"Unity Transport\" component."); + } + } +#endif + #if UTP_TRANSPORT_2_0_ABOVE if (m_UseWebSockets) { diff --git a/com.unity.netcode.gameobjects/Runtime/com.unity.netcode.runtime.asmdef b/com.unity.netcode.gameobjects/Runtime/com.unity.netcode.runtime.asmdef index 43433abf76..beeb62a64f 100644 --- a/com.unity.netcode.gameobjects/Runtime/com.unity.netcode.runtime.asmdef +++ b/com.unity.netcode.gameobjects/Runtime/com.unity.netcode.runtime.asmdef @@ -36,6 +36,11 @@ "name": "com.unity.transport", "expression": "2.0.0-exp", "define": "UTP_TRANSPORT_2_0_ABOVE" + }, + { + "name": "com.unity.transport", + "expression": "2.1.0", + "define": "UTP_TRANSPORT_2_1_ABOVE" } ] }