Fix issues with multiplayer button

This commit is contained in:
Lncvrt committed 2026-03-16 23:03:01 -07:00
1 parent 06ba845790
commit 475168cc45
1 file changed
+9
@@ -242,9 +242,17 @@ public class PlayModePrefab : MonoBehaviour {
nothingBerryChance.onSelect.AddListener((value) => OnSelect(value, nothingBerryChance));
nothingBerryChance.onDeselect.AddListener((value) => OnDeselect(value, nothingBerryChance));
WebsocketHandler.Instance._Connection.StateChanged += OnStateChanged;
WebsocketHandler.Instance._Connection.MessageReceived += OnMessageReceived;
}
private void OnStateChanged(WebSocketConnection connection, WebSocketState oldState, WebSocketState newState) {
multiplayerButton.gameObject.SetActive(newState == WebSocketState.Connected);
var pos = autoButton.transform.localPosition;
pos.x = newState == WebSocketState.Connected ? 155 : 0;
autoButton.transform.localPosition = pos;
}
private void OnMessageReceived(WebSocketConnection connection, WebSocketMessage message) {
if (message.String != null && connection.State == WebSocketState.Connected) {
JToken data = JToken.Parse(message.String);
@@ -297,6 +305,7 @@ public class PlayModePrefab : MonoBehaviour {
}
void OnDestroy() {
WebsocketHandler.Instance._Connection.StateChanged -= OnStateChanged;
WebsocketHandler.Instance._Connection.MessageReceived -= OnMessageReceived;
}