Skip to content

Commit 809b279

Browse files
committed
fix(NetworkAuthenticator): Unity 2019 Compatibility
1 parent 0cd8c39 commit 809b279

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Assets/Mirror/Authenticators/UniqueNameAuthenticator.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
namespace Mirror.Authenticators
99
{
10+
#if !UNITY_2020_3_OR_NEWER
11+
/// <summary>UnityEvent subclass for notifying when a client is authenticated on the server</summary>
12+
[Serializable]
13+
public class StringEvent : UnityEvent<string> { }
14+
#endif
15+
1016
public class UniqueNameAuthenticator : NetworkAuthenticator
1117
{
1218
readonly HashSet<NetworkConnectionToClient> connectionsPendingDisconnect = new HashSet<NetworkConnectionToClient>();
@@ -16,8 +22,14 @@ public class UniqueNameAuthenticator : NetworkAuthenticator
1622
public string playerName;
1723

1824
[Header("Events")]
25+
#if !UNITY_2020_3_OR_NEWER
26+
// Unity 2019 compatibility
27+
public StringEvent OnAuthSuccess = new StringEvent();
28+
public StringEvent OnAuthFailure = new StringEvent();
29+
#else
1930
public UnityEvent<string> OnAuthSuccess = new UnityEvent<string>();
2031
public UnityEvent<string> OnAuthFailure = new UnityEvent<string>();
32+
#endif
2133

2234
#region Messages
2335

Assets/Mirror/Core/NetworkAuthenticator.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44

55
namespace Mirror
66
{
7+
#if !UNITY_2020_3_OR_NEWER
8+
/// <summary>UnityEvent subclass for notifying when a client is authenticated on the server</summary>
9+
[Serializable]
10+
public class NetworkConnectionToClientEvent : UnityEvent<NetworkConnectionToClient> { }
11+
#endif
12+
713
/// <summary>Base class for implementing component-based authentication during the Connect phase</summary>
814
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-authenticators")]
915
public abstract class NetworkAuthenticator : MonoBehaviour
1016
{
1117
/// <summary>Notify subscribers on the server when a client is authenticated</summary>
1218
[Header("Event Listeners (optional)")]
1319
[Tooltip("Mirror has an internal subscriber to this event. You can add your own here.")]
20+
#if !UNITY_2020_3_OR_NEWER
21+
// Unity 2019 compatibility
22+
public NetworkConnectionToClientEvent OnServerAuthenticated = new NetworkConnectionToClientEvent();
23+
#else
1424
public UnityEvent<NetworkConnectionToClient> OnServerAuthenticated = new UnityEvent<NetworkConnectionToClient>();
25+
#endif
1526

1627
/// <summary>Notify subscribers on the client when the client is authenticated</summary>
1728
[Tooltip("Mirror has an internal subscriber to this event. You can add your own here.")]

0 commit comments

Comments
 (0)