GameCenter requires that you give access to a view controller to display the leader board.
The function in question is:
presentModalViewController:animated:
To do so is quite easy.
In “AppController.mm”,
-
scroll to
int OpenEAGL_UnityCallback(UIWindow** window, int* screenWidth, int* screenHeight, int* openglesVersion) -
comment out
[_window addSubview:view] -
below put
_window.rootViewController = controller; -
wherever the view controller is necessary, you can put
[[[UIApplication sharedApplication] keyWindow] rootViewController]
an example to display the leaderboard:
// displaying the default leaderboard
-(void) showLeaderboard {
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil) {
leaderboardController.leaderboardDelegate = self;
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:leaderboardController animated:YES];
}
}
![]()