Skip to content

fix: unet removed from unity trunk #1678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

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

## [Unreleased]
### Added
### Changed

### Fixed
- 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)


## [1.0.0-pre.5] - 2022-01-26

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_UNET_PRESENT
using System;
#if UNITY_EDITOR
using UnityEditor;
Expand Down Expand Up @@ -50,3 +51,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
#endif
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_UNET_PRESENT
#pragma warning disable 618 // disable is obsolete
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System;
Expand Down Expand Up @@ -283,3 +284,4 @@ private ConnectionConfig GetConfig()
}
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#pragma warning restore 618 // restore is obsolete
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"name": "com.unity.multiplayer.tools",
"expression": "",
"define": "MULTIPLAYER_TOOLS"
},
{
"name": "Unity",
"expression": "(0,2022.2.0a5)",
"define": "UNITY_UNET_PRESENT"
}
],
"noEngineReferences": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using UnityEngine;
using NUnit.Framework;
using Unity.Netcode.Transports.UNET;

namespace Unity.Netcode.RuntimeTests
{
Expand Down Expand Up @@ -68,7 +67,11 @@ public static bool StartNetworkManager(out NetworkManager networkManager, Networ

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

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

NetworkManagerObject.NetworkConfig = networkConfig;

unetTransport.ConnectAddress = "127.0.0.1";
unetTransport.ConnectPort = 7777;
unetTransport.ServerListenPort = 7777;
unetTransport.MessageBufferSize = 65535;
unetTransport.MaxConnections = 100;
unetTransport.MessageSendMode = UNetTransport.SendMode.Immediately;
NetworkManagerObject.NetworkConfig.NetworkTransport = unetTransport;
NetworkManagerObject.NetworkConfig.NetworkTransport = sipTransport;

// Starts the network manager in the mode specified
StartNetworkManagerMode(managerMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"name": "com.unity.multiplayer.tools",
"expression": "",
"define": "MULTIPLAYER_TOOLS"
},
{
"name": "Unity",
"expression": "(0,2022.2.0a5)",
"define": "UNITY_UNET_PRESENT"
}
],
"noEngineReferences": false
Expand Down
22 changes: 20 additions & 2 deletions testproject/Assets/Scripts/CommandLineHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using Unity.Netcode;
#if UNITY_UNET_PRESENT
using Unity.Netcode.Transports.UNET;

#endif

/// <summary>
/// Provides basic command line handling capabilities
Expand Down Expand Up @@ -200,9 +201,20 @@ private void SetTransportAddress(string address)
var transport = NetworkManager.Singleton.NetworkConfig.NetworkTransport;
switch (transport)
{
#if UNITY_UNET_PRESENT
case UNetTransport unetTransport:
unetTransport.ConnectAddress = address;
break;
#endif
case UnityTransport utpTransport:
{
utpTransport.ConnectionData.Address = address;
if (utpTransport.ConnectionData.ServerListenAddress == string.Empty)
{
utpTransport.ConnectionData.ServerListenAddress = address;
}
break;
}
}
}

Expand All @@ -211,10 +223,17 @@ private void SetPort(ushort port)
var transport = NetworkManager.Singleton.NetworkConfig.NetworkTransport;
switch (transport)
{
#if UNITY_UNET_PRESENT
case UNetTransport unetTransport:
unetTransport.ConnectPort = port;
unetTransport.ServerListenPort = port;
break;
#endif
case UnityTransport utpTransport:
{
utpTransport.ConnectionData.Port = port;
break;
}
}
}
}
Expand All @@ -232,6 +251,5 @@ private void Start()
{
s_CommandLineProcessorInstance = new CommandLineProcessor(Environment.GetCommandLineArgs());
}

}
}
5 changes: 5 additions & 0 deletions testproject/Assets/Scripts/testproject.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"name": "com.unity.services.relay",
"expression": "0.0.1-preview.3",
"define": "ENABLE_RELAY_SERVICE"
},
{
"name": "Unity",
"expression": "(0,2022.2.0a5)",
"define": "UNITY_UNET_PRESENT"
}
],
"noEngineReferences": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"versionDefines": [
{
"name": "Unity",
"expression": "(0,2022.2.0a5)",
"define": "UNITY_UNET_PRESENT"
}
],
"noEngineReferences": false
}
}