Skip to content

Commit 248aa21

Browse files
chore: remove deprecated relay package (#3201)
* update updating the manifest to remove the deprecated relay package * update wrapping legacy code to prevent it from being compiled without the deprecated relay package. (we might just remove all of this script eventually) * update updating the project version and settings as well as the default prefab list. * style Fixing import ordering. * style fixing the import order
1 parent 53ec0e6 commit 248aa21

File tree

7 files changed

+72
-49
lines changed

7 files changed

+72
-49
lines changed

testproject/Assets/DefaultNetworkPrefabs.asset

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,7 @@ MonoBehaviour:
219219
SourceHashToOverride: 0
220220
OverridingTargetPrefab: {fileID: 0}
221221
- Override: 0
222-
Prefab: {fileID: 8133991607019124060, guid: 421bcf732fe69486d8abecfa5eee63bb,
223-
type: 3}
224-
SourcePrefabToOverride: {fileID: 0}
225-
SourceHashToOverride: 0
226-
OverridingTargetPrefab: {fileID: 0}
227-
- Override: 0
228-
Prefab: {fileID: 3439633038736912633, guid: 398aad09d8b2a47eba664a076763cdcc,
222+
Prefab: {fileID: 3830151999068797299, guid: 074ae41741b33f84ca886d5b8dc482d2,
229223
type: 3}
230224
SourcePrefabToOverride: {fileID: 0}
231225
SourceHashToOverride: 0

testproject/Assets/Scripts/ConnectionModeScript.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#if ENABLE_RELAY_SERVICE
2+
using System;
3+
#endif
14
using System.Collections;
2-
using UnityEngine;
35
using Unity.Netcode;
46
using Unity.Netcode.Transports.UTP;
5-
using UnityEngine.SceneManagement;
67
#if ENABLE_RELAY_SERVICE
7-
using System;
88
using Unity.Services.Core;
99
using Unity.Services.Authentication;
1010
#endif
11+
using UnityEngine;
12+
using UnityEngine.SceneManagement;
13+
1114

1215
/// <summary>
1316
/// Used in tandem with the ConnectModeButtons prefab asset in test project
@@ -23,8 +26,10 @@ public class ConnectionModeScript : MonoBehaviour
2326
[SerializeField]
2427
private GameObject m_JoinCodeInput;
2528

29+
#if ENABLE_RELAY_SERVICE
2630
[SerializeField]
2731
private int m_MaxConnections = 10;
32+
#endif
2833

2934
[SerializeField]
3035
private LoadSceneMode m_ClientSynchronizationMode;
@@ -126,8 +131,10 @@ private void OnServicesInitialized()
126131
if (HasRelaySupport())
127132
{
128133
m_JoinCodeInput.SetActive(true);
134+
#if ENABLE_RELAY_SERVICE
129135
m_ConnectionModeButtons?.SetActive(false || AuthenticationService.Instance.IsSignedIn);
130136
m_AuthenticationButtons?.SetActive(NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && !AuthenticationService.Instance.IsSignedIn);
137+
#endif
131138
}
132139
}
133140

@@ -138,11 +145,13 @@ public void OnStartServerButton()
138145
{
139146
if (NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && m_ConnectionModeButtons)
140147
{
148+
#if ENABLE_RELAY_SERVICE
141149
if (HasRelaySupport())
142150
{
143151
StartCoroutine(StartRelayServer(StartServer));
144152
}
145153
else
154+
#endif
146155
{
147156
StartServer();
148157
}
@@ -170,13 +179,13 @@ private void OnServerStopped(bool obj)
170179
}
171180
}
172181

173-
182+
#if ENABLE_RELAY_SERVICE
174183
/// <summary>
175184
/// Coroutine that handles starting MLAPI in server mode if Relay is enabled
176185
/// </summary>
177186
private IEnumerator StartRelayServer(Action postAllocationAction)
178187
{
179-
#if ENABLE_RELAY_SERVICE
188+
180189
m_ConnectionModeButtons?.SetActive(false);
181190

182191
var serverRelayUtilityTask = RelayUtility.AllocateRelayServerAndGetJoinCode(m_MaxConnections);
@@ -198,11 +207,8 @@ private IEnumerator StartRelayServer(Action postAllocationAction)
198207
NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(ipv4address, port, allocationIdBytes, key, connectionData);
199208

200209
postAllocationAction();
201-
#else
202-
yield return null;
203-
#endif
204210
}
205-
211+
#endif
206212

207213
/// <summary>
208214
/// Handles starting netcode in host mode
@@ -211,11 +217,13 @@ public void OnStartHostButton()
211217
{
212218
if (NetworkManager.Singleton && !NetworkManager.Singleton.IsListening && m_ConnectionModeButtons)
213219
{
220+
#if ENABLE_RELAY_SERVICE
214221
if (HasRelaySupport())
215222
{
216223
StartCoroutine(StartRelayServer(StartHost));
217224
}
218225
else
226+
#endif
219227
{
220228
StartHost();
221229
}

testproject/Assets/Scripts/RelayUtility.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if ENABLE_RELAY_SERVICE
12
using System;
23
using System.Threading.Tasks;
34
using Unity.Services.Relay;
@@ -56,3 +57,4 @@ public class RelayUtility
5657
return (allocation.RelayServer.IpV4, (ushort)allocation.RelayServer.Port, allocation.AllocationIdBytes, allocation.ConnectionData, allocation.HostConnectionData, allocation.Key);
5758
}
5859
}
60+
#endif

testproject/Assets/Scripts/UIController.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
using UnityEngine;
21
using Unity.Netcode;
32
using Unity.Netcode.Transports.UTP;
43
#if ENABLE_RELAY_SERVICE
54
using Unity.Services.Core;
65
using Unity.Services.Authentication;
76
#endif
7+
using UnityEngine;
8+
89

910
public class UIController : MonoBehaviour
1011
{
@@ -49,10 +50,10 @@ private void HideButtons()
4950
ButtonsRoot.SetActive(false);
5051
}
5152

52-
53+
#if ENABLE_RELAY_SERVICE
5354
public async void OnSignIn()
5455
{
55-
#if ENABLE_RELAY_SERVICE
56+
5657
await UnityServices.InitializeAsync();
5758
Debug.Log("OnSignIn");
5859
await AuthenticationService.Instance.SignInAnonymouslyAsync();
@@ -64,6 +65,7 @@ public async void OnSignIn()
6465
JoinCode.SetActive(true);
6566
AuthButton.SetActive(false);
6667
}
67-
#endif
68+
6869
}
70+
#endif
6971
}

testproject/Packages/manifest.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
{
22
"dependencies": {
3-
"com.unity.addressables": "2.1.0",
4-
"com.unity.ai.navigation": "2.0.0",
5-
"com.unity.collab-proxy": "2.4.3",
6-
"com.unity.ide.rider": "3.0.28",
3+
"com.unity.addressables": "2.2.2",
4+
"com.unity.ai.navigation": "2.0.5",
5+
"com.unity.collab-proxy": "2.6.0",
6+
"com.unity.ide.rider": "3.0.31",
77
"com.unity.ide.visualstudio": "2.0.22",
88
"com.unity.mathematics": "1.3.2",
99
"com.unity.netcode.gameobjects": "file:../../com.unity.netcode.gameobjects",
1010
"com.unity.package-validation-suite": "0.49.0-preview",
11-
"com.unity.services.authentication": "3.3.3",
12-
"com.unity.services.core": "1.13.0",
13-
"com.unity.services.relay": "1.0.5",
14-
"com.unity.test-framework": "1.4.4",
11+
"com.unity.services.authentication": "3.4.0",
12+
"com.unity.services.core": "1.14.0",
13+
"com.unity.test-framework": "1.4.5",
1514
"com.unity.test-framework.performance": "3.0.3",
1615
"com.unity.timeline": "1.8.7",
17-
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.9",
16+
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10",
1817
"com.unity.ugui": "2.0.0",
1918
"com.unity.modules.accessibility": "1.0.0",
2019
"com.unity.modules.ai": "1.0.0",

0 commit comments

Comments
 (0)