Skip to content

Commit 1b6598d

Browse files
fix: unet removed from unity trunk (#1678)
* fix Updating the NGO assembly. * fix excluding unet if it is not present. * fix Missed a few spots * fix CommandLineHandler had references to UNetTransport * fix Excluding Unity.Netcode.Transports.UNET from NetworkManagerHelper. * style removing commented out UNet references and adding additional comments. * update removing the relay stuff as it was not needed. * update Adding UnityTransport support to the CommandLineHandler. * update
1 parent e3ace4e commit 1b6598d

File tree

9 files changed

+61
-14
lines changed

9 files changed

+61
-14
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).
88

9+
## [Unreleased]
10+
### Added
11+
### Changed
12+
13+
### Fixed
14+
- Fixed: Issue where Alpha release versions of Unity (version 20202.2.0a5 and later) will not compile due to the UNet Transport no longer existing (#1678)
15+
16+
917
## [1.0.0-pre.5] - 2022-01-26
1018

1119
### Added

com.unity.netcode.gameobjects/Runtime/Transports/UNET/UNetChannel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if UNITY_UNET_PRESENT
12
using System;
23
#if UNITY_EDITOR
34
using UnityEditor;
@@ -50,3 +51,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
5051
#endif
5152
}
5253
}
54+
#endif

com.unity.netcode.gameobjects/Runtime/Transports/UNET/UNetTransport.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if UNITY_UNET_PRESENT
12
#pragma warning disable 618 // disable is obsolete
23
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
34
using System;
@@ -283,3 +284,4 @@ private ConnectionConfig GetConfig()
283284
}
284285
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
285286
#pragma warning restore 618 // restore is obsolete
287+
#endif

com.unity.netcode.gameobjects/Runtime/com.unity.netcode.runtime.asmdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"name": "com.unity.multiplayer.tools",
2525
"expression": "",
2626
"define": "MULTIPLAYER_TOOLS"
27+
},
28+
{
29+
"name": "Unity",
30+
"expression": "(0,2022.2.0a5)",
31+
"define": "UNITY_UNET_PRESENT"
2732
}
2833
],
2934
"noEngineReferences": false

com.unity.netcode.gameobjects/Tests/Runtime/Helpers/NetworkManagerHelper.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44
using NUnit.Framework;
5-
using Unity.Netcode.Transports.UNET;
65

76
namespace Unity.Netcode.RuntimeTests
87
{
@@ -68,7 +67,11 @@ public static bool StartNetworkManager(out NetworkManager networkManager, Networ
6867

6968
Debug.Log($"{nameof(NetworkManager)} Instantiated.");
7069

71-
var unetTransport = NetworkManagerGameObject.AddComponent<UNetTransport>();
70+
// NOTE: For now we only use SIPTransport for tests until UnityTransport
71+
// has been verified working in nightly builds
72+
// TODO-MTT-2486: Provide support for other transports once tested and verified
73+
// working on consoles.
74+
var sipTransport = NetworkManagerGameObject.AddComponent<SIPTransport>();
7275
if (networkConfig == null)
7376
{
7477
networkConfig = new NetworkConfig
@@ -78,14 +81,7 @@ public static bool StartNetworkManager(out NetworkManager networkManager, Networ
7881
}
7982

8083
NetworkManagerObject.NetworkConfig = networkConfig;
81-
82-
unetTransport.ConnectAddress = "127.0.0.1";
83-
unetTransport.ConnectPort = 7777;
84-
unetTransport.ServerListenPort = 7777;
85-
unetTransport.MessageBufferSize = 65535;
86-
unetTransport.MaxConnections = 100;
87-
unetTransport.MessageSendMode = UNetTransport.SendMode.Immediately;
88-
NetworkManagerObject.NetworkConfig.NetworkTransport = unetTransport;
84+
NetworkManagerObject.NetworkConfig.NetworkTransport = sipTransport;
8985

9086
// Starts the network manager in the mode specified
9187
StartNetworkManagerMode(managerMode);

com.unity.netcode.gameobjects/Tests/Runtime/com.unity.netcode.runtimetests.asmdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"name": "com.unity.multiplayer.tools",
3030
"expression": "",
3131
"define": "MULTIPLAYER_TOOLS"
32+
},
33+
{
34+
"name": "Unity",
35+
"expression": "(0,2022.2.0a5)",
36+
"define": "UNITY_UNET_PRESENT"
3237
}
3338
],
3439
"noEngineReferences": false

testproject/Assets/Scripts/CommandLineHandler.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
using UnityEngine;
44
using UnityEngine.SceneManagement;
55
using Unity.Netcode;
6+
#if UNITY_UNET_PRESENT
67
using Unity.Netcode.Transports.UNET;
7-
8+
#endif
89

910
/// <summary>
1011
/// Provides basic command line handling capabilities
@@ -200,9 +201,20 @@ private void SetTransportAddress(string address)
200201
var transport = NetworkManager.Singleton.NetworkConfig.NetworkTransport;
201202
switch (transport)
202203
{
204+
#if UNITY_UNET_PRESENT
203205
case UNetTransport unetTransport:
204206
unetTransport.ConnectAddress = address;
205207
break;
208+
#endif
209+
case UnityTransport utpTransport:
210+
{
211+
utpTransport.ConnectionData.Address = address;
212+
if (utpTransport.ConnectionData.ServerListenAddress == string.Empty)
213+
{
214+
utpTransport.ConnectionData.ServerListenAddress = address;
215+
}
216+
break;
217+
}
206218
}
207219
}
208220

@@ -211,10 +223,17 @@ private void SetPort(ushort port)
211223
var transport = NetworkManager.Singleton.NetworkConfig.NetworkTransport;
212224
switch (transport)
213225
{
226+
#if UNITY_UNET_PRESENT
214227
case UNetTransport unetTransport:
215228
unetTransport.ConnectPort = port;
216229
unetTransport.ServerListenPort = port;
217230
break;
231+
#endif
232+
case UnityTransport utpTransport:
233+
{
234+
utpTransport.ConnectionData.Port = port;
235+
break;
236+
}
218237
}
219238
}
220239
}
@@ -232,6 +251,5 @@ private void Start()
232251
{
233252
s_CommandLineProcessorInstance = new CommandLineProcessor(Environment.GetCommandLineArgs());
234253
}
235-
236254
}
237255
}

testproject/Assets/Scripts/testproject.asmdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"name": "com.unity.services.relay",
2323
"expression": "0.0.1-preview.3",
2424
"define": "ENABLE_RELAY_SERVICE"
25+
},
26+
{
27+
"name": "Unity",
28+
"expression": "(0,2022.2.0a5)",
29+
"define": "UNITY_UNET_PRESENT"
2530
}
2631
],
2732
"noEngineReferences": false

testproject/Assets/Tests/Runtime/testproject.runtimetests.asmdef

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"defineConstraints": [
2020
"UNITY_INCLUDE_TESTS"
2121
],
22-
"versionDefines": [],
22+
"versionDefines": [
23+
{
24+
"name": "Unity",
25+
"expression": "(0,2022.2.0a5)",
26+
"define": "UNITY_UNET_PRESENT"
27+
}
28+
],
2329
"noEngineReferences": false
24-
}
30+
}

0 commit comments

Comments
 (0)