2022 Graphics & Games
WWDC22 · 10 min · Graphics & Games
Reach new players with Game Center dashboard
Meet the Game Center activity dashboard and discover how it can help your game reach new players. We’ll introduce you to the dashboard and profiles and explore how they can track player achievements, high scores, and leaderboard changes for your game. We’ll also show you how to add Game Center to your Unity game project using the Game Center plug-in.
Watch at developer.apple.com ↗Code shown on screen · 4 snippets
Authenticate the local player
// Authenticate the local player
import GameKit
class TitleScreenViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Authenticate the local player
GKLocalPlayer.local.authenticateHandler = { viewController, error in
if let viewController = viewController {
// Present the view controller from Game Center.
return
}
}
}
} Authenticate the local player
// Authenticate the local player
using Apple.GameKit;
public class MyGameManager : MonoBehaviour
{
private GKLocalPlayer _localPlayer;
private async Task Start()
{
try
{
_localPlayer = await GKLocalPlayer.Authenticate();
}
catch (Exception exception)
{
// Handle exception...
}
}
} Show the Access Point
// Show the Access Point
import GameKit
class MenuScreenViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
GKAccessPoint.shared.location = .topLeading
GKAccessPoint.shared.isActive = true
}
} Show the Access Point
// Show the Access Point
GKAccessPoint.Shared.Location =
GKAcessPoint.GKAccessPointLocation.TopLeading;
GKAccessPoint.Shared.IsActive = true; Resources
Related sessions
-
27 min -
22 min -
26 min -
18 min -
24 min -
25 min