Created
June 15, 2020 18:39
-
-
Save herpdederp/a2f3e8b0dd1a2bf94bfc54af28c5ce81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Update() | |
{ | |
if (BoltNetwork.IsServer == false) { return; } | |
if (Input.GetKeyDown(KeyCode.Space)) | |
{ | |
IncreasePlayerCount(1); | |
} | |
if (Input.GetKeyDown(KeyCode.L)) | |
{ | |
ShowPlayerCount(); | |
} | |
} | |
private void ShowPlayerCount() | |
{ | |
var session = BoltMatchmaking.CurrentSession as PhotonSession; | |
if (session != null) | |
{ | |
var key = "playerCount"; | |
if (session.Properties.ContainsKey(key)) | |
{ | |
Debug.LogFormat("Current Player Count: {0}", session.Properties[key]); | |
} | |
} | |
} | |
private void IncreasePlayerCount(int value) | |
{ | |
var session = BoltMatchmaking.CurrentSession as PhotonSession; | |
if (session != null) | |
{ | |
var key = "playerCount"; | |
var currentCount = 0; | |
if (session.Properties.ContainsKey(key)) | |
{ | |
currentCount = (int)session.Properties[key]; | |
} | |
var updateToken = new PhotonRoomProperties(); | |
updateToken[key] = currentCount + value; | |
BoltMatchmaking.UpdateSession(updateToken); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment