Skip to content

Commit 8c5a613

Browse files
committed
Merge branch 'release/GDC2022' into fix/not-returning-to-mainmenu-when-reconnect-fails
2 parents 3400da0 + b956e5d commit 8c5a613

File tree

7 files changed

+75
-27
lines changed

7 files changed

+75
-27
lines changed

.github/workflows/leak_detect.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Detect Project ID leak
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the main branch
6+
push:
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
# This workflow contains a single job called "build"
14+
check:
15+
# The type of runner that the job will run on
16+
runs-on: ubuntu-latest
17+
18+
# Steps represent a sequence of tasks that will be executed as part of the job
19+
steps:
20+
- name: Checkout github repo (+ download lfs dependencies)
21+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
22+
uses: actions/checkout@v2
23+
with:
24+
lfs: true
25+
- name: Checkout LFS objects # needs to be done as a second step, lfs:true above just sets references, but doesn't actually dereference them...
26+
run: git lfs checkout
27+
# Find in project settings if there's any value in between "cloudProjectId: " and end of line. This exits 1 and fails the step if there's text there.
28+
- name: Run a one-line script
29+
run: python3 -c "import re; import sys;content=open('ProjectSettings/ProjectSettings.asset').read();res = re.search(r'.*cloudProjectId:.*\w+\s*\n', content)!=None;status = 1 if res else 0; print('status '+str(status)); sys.exit(res)"
30+
- name: Post to slack on failure
31+
if: ${{ failure() }}
32+
uses: slackapi/[email protected]
33+
with:
34+
# Slack channel id, channel name, or user id to post message.
35+
# See also: https://api.slack.com/methods/chat.postMessage#channels
36+
channel-id: 'G01H7JP4AP2' # private channel
37+
# For posting a simple plain text message
38+
slack-message: "Project ID LEAK DETECTED: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
39+
env:
40+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} # can be found in https://api.slack.com/apps/

Assets/BossRoom/Scenes/MainMenu.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:15103b3bc112b4f77c6bbb6d466fed06b3d55663ed94c89644ebd88d256d3454
3-
size 72582
2+
oid sha256:a19c8354d1b4f8323bda3fdabc60b4d1f26faf395196546ff67da590e56fded1
3+
size 78835

Assets/BossRoom/Scripts/Client/Game/State/ClientMainMenuState.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class ClientMainMenuState : GameStateBehaviour
2929

3030
[SerializeField] NameGenerationData m_NameGenerationData;
3131
[SerializeField] LobbyUIMediator m_LobbyUIMediator;
32+
[SerializeField] IPUIMediator m_IPUIMediator;
3233

3334
[SerializeField] CanvasGroup m_MainMenuButtonsCanvasGroup;
3435
[SerializeField] GameObject m_SignInSpinner;
@@ -47,6 +48,7 @@ void InjectDependenciesAndInitialize(AuthenticationServiceFacade authServiceFaca
4748

4849
m_Scope.BindInstanceAsSingle(m_NameGenerationData);
4950
m_Scope.BindInstanceAsSingle(m_LobbyUIMediator);
51+
m_Scope.BindInstanceAsSingle(m_IPUIMediator);
5052

5153
var unityAuthenticationInitOptions = new InitializationOptions();
5254

@@ -115,5 +117,11 @@ public void OnStartClicked()
115117
m_LobbyUIMediator.ToggleJoinLobbyUI();
116118
m_LobbyUIMediator.Show();
117119
}
120+
121+
public void OnDirectIPClicked()
122+
{
123+
m_LobbyUIMediator.Hide();
124+
m_IPUIMediator.Show();
125+
}
118126
}
119127
}

Assets/BossRoom/Scripts/Client/UI/IPUIMediator.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class IPUIMediator : MonoBehaviour
2929
[SerializeField] UITinter m_JoinTabButtonBorderTinter;
3030

3131
[SerializeField] UITinter m_HostTabButtonTinter;
32-
32+
3333
[SerializeField] UITinter m_HostTabButtonBorderTinter;
3434

3535
[SerializeField] GameObject m_SignInSpinner;
@@ -63,22 +63,6 @@ void Start()
6363
ToggleCreateIPUI();
6464
}
6565

66-
void Update()
67-
{
68-
if (Input.touchCount == k_NbTouchesToOpenWindow && AnyTouchDown() ||
69-
m_OpenIPWindowKeyCode != KeyCode.None && Input.GetKeyDown(m_OpenIPWindowKeyCode))
70-
{
71-
if (m_CanvasGroup.interactable)
72-
{
73-
Hide();
74-
}
75-
else
76-
{
77-
Show();
78-
}
79-
}
80-
}
81-
8266
static bool AnyTouchDown()
8367
{
8468
foreach (var touch in Input.touches)

Assets/BossRoom/Scripts/Client/UI/PostGameUI.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
using UnityEngine.SceneManagement;
33
using UnityEngine.UI;
44
using TMPro;
5+
using Unity.Multiplayer.Samples.BossRoom.Shared;
6+
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
57
using Unity.Multiplayer.Samples.Utilities;
68
using Unity.Netcode;
9+
using UnityEngine.Assertions;
710

811
namespace Unity.Multiplayer.Samples.BossRoom.Visual
912
{
@@ -12,6 +15,8 @@ namespace Unity.Multiplayer.Samples.BossRoom.Visual
1215
/// </summary>
1316
public class PostGameUI : MonoBehaviour
1417
{
18+
ApplicationController m_ApplicationController;
19+
1520
[SerializeField]
1621
private Light m_SceneLight;
1722

@@ -36,6 +41,18 @@ public class PostGameUI : MonoBehaviour
3641
[SerializeField]
3742
private Color m_LoseLightColor;
3843

44+
[Inject]
45+
void InjectDependencies(ApplicationController applicationController)
46+
{
47+
m_ApplicationController = applicationController;
48+
}
49+
50+
void Awake()
51+
{
52+
// This is needed because the post game UI is part of the PostGame scene so we need to manually inject dependencies on awake.
53+
DIScope.RootScope.InjectIn(this);
54+
}
55+
3956
void Start()
4057
{
4158
// only hosts can restart the game, other players see a wait message
@@ -77,18 +94,15 @@ void SetPostGameUI(WinState winState)
7794
public void OnPlayAgainClicked()
7895
{
7996
// this should only ever be called by the Host - so just go ahead and switch scenes
97+
Assert.IsTrue(NetworkManager.Singleton.IsServer);
8098
SceneLoaderWrapper.Instance.LoadScene("CharSelect");
8199

82100
// FUTURE: could be improved to better support a dedicated server architecture
83101
}
84102

85103
public void OnMainMenuClicked()
86104
{
87-
// Player is leaving this group - leave current network connection first
88-
var gameNetPortal = GameObject.FindGameObjectWithTag("GameNetPortal").GetComponent<GameNetPortal>();
89-
gameNetPortal.RequestDisconnect();
90-
91-
SceneLoaderWrapper.Instance.LoadScene("MainMenu");
105+
m_ApplicationController.LeaveSession();
92106
}
93107
}
94108
}

Assets/BossRoom/Scripts/Shared/ApplicationController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
55
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Infrastructure;
66
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Lobbies;
7+
using Unity.Multiplayer.Samples.Utilities;
78
using Unity.Netcode;
89
using UnityEngine;
910
using UnityEngine.SceneManagement;
@@ -106,7 +107,8 @@ public void LeaveSession()
106107
{
107108
gameNetPortal.RequestDisconnect();
108109
}
109-
SceneManager.LoadScene("MainMenu");
110+
111+
SceneLoaderWrapper.Instance.LoadScene("MainMenu");
110112
}
111113

112114
public void QuitGame()

Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void AddOnSceneEventCallback()
6969
/// <param name="loadSceneMode">If LoadSceneMode.Single then all current Scenes will be unloaded before loading.</param>
7070
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode = LoadSceneMode.Single)
7171
{
72-
if (m_NetworkManager != null && m_NetworkManager.IsListening && m_NetworkManager.NetworkConfig.EnableSceneManagement)
72+
if (m_NetworkManager != null && m_NetworkManager.IsListening && !m_NetworkManager.ShutdownInProgress && m_NetworkManager.NetworkConfig.EnableSceneManagement)
7373
{
7474
if (m_NetworkManager.IsServer)
7575
{
@@ -90,7 +90,7 @@ public void LoadScene(string sceneName, LoadSceneMode loadSceneMode = LoadSceneM
9090

9191
void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
9292
{
93-
if (m_NetworkManager == null || !m_NetworkManager.IsListening || !m_NetworkManager.NetworkConfig.EnableSceneManagement)
93+
if (m_NetworkManager == null || !m_NetworkManager.IsListening || m_NetworkManager.ShutdownInProgress || !m_NetworkManager.NetworkConfig.EnableSceneManagement)
9494
{
9595
m_ClientLoadingScreen.StopLoadingScreen();
9696
}

0 commit comments

Comments
 (0)