Skip to content

Commit 30815f7

Browse files
committed
Fixed injection in ConnectionStates
1 parent b9afaca commit 30815f7

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Assets/Scenes/Startup.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:3054122b6372d0032533c9a84ec7c83b2afb7a0096021d97a324518efbae84e9
3-
size 46841
2+
oid sha256:48a24b280794a53ab92b88c560dba8dddc996e910e534a952e60fa0bad85a1cc
3+
size 45753

Assets/Scripts/ConnectionManagement/ConnectionManager.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public class ConnectionManager : MonoBehaviour
6767
NetworkObject m_GameState;
6868
public NetworkObject GameState => m_GameState;
6969

70+
[Inject]
71+
IObjectResolver m_Resolver;
72+
7073
public int MaxConnectedPlayers = 8;
7174

7275
internal readonly OfflineState m_Offline = new OfflineState();
@@ -84,6 +87,12 @@ void Awake()
8487

8588
void Start()
8689
{
90+
List<ConnectionState> states = new() { m_Offline, m_ClientConnecting, m_ClientConnected, m_ClientReconnecting, m_DisconnectingWithReason, m_StartingHost, m_Hosting };
91+
foreach (var connectionState in states)
92+
{
93+
m_Resolver.Inject(connectionState);
94+
}
95+
8796
m_CurrentState = m_Offline;
8897

8998
NetworkManager.OnClientConnectedCallback += OnClientConnectedCallback;
@@ -101,16 +110,6 @@ void OnDestroy()
101110

102111
}
103112

104-
[Inject]
105-
void InjectDependencies(LifetimeScope scope)
106-
{
107-
List<ConnectionState> states = new() { m_Offline, m_ClientConnecting, m_ClientConnected, m_ClientReconnecting, m_DisconnectingWithReason, m_StartingHost, m_Hosting };
108-
foreach (var connectionState in states)
109-
{
110-
scope.Container.Inject(connectionState);
111-
}
112-
}
113-
114113
internal void ChangeState(ConnectionState nextState)
115114
{
116115
Debug.Log($"Changed connection state from {m_CurrentState.GetType().Name} to {nextState.GetType().Name}.");

0 commit comments

Comments
 (0)