简体   繁体   English

在导出的Unity Xcode项目上显示Gamecenter

[英]Showing Gamecenter on an exported Unity Xcode project

I have an iOS Unity project which has been built and now I have a Xcode project. 我有一个已构建的iOS Unity项目,现在有一个Xcode项目。 Now I want to Implement Gamecenter but I just can't seem to find the rootviewcontroller to show the GKLeaderboardViewController. 现在我想实现Gamecenter,但似乎找不到rootviewcontroller来显示GKLeaderboardViewController。 On a native app, I would simply do the following: 在本地应用程序上,我只需执行以下操作:

#import "AppDelegate.h"

AppDelegate *_delegate = [UIApplication sharedApplication].delegate;
[_delegate.viewController presentModalViewController: leaderboardController animated: YES];

But Unity messes up the code and I only have an AppController.h and an AppController.mm 但是Unity弄乱了代码,我只有一个AppController.h和一个AppController.mm

Anyone has managed to resolve this? 有人设法解决了吗?

Looking inside the AppController.mm you can find: 在AppController.mm内部,您可以找到:

if( [_window respondsToSelector:@selector(rootViewController)] )
    _window.rootViewController = controller;

So you can get root view controller by calling 因此,您可以通过调用获取根视图控制器

[[UIApplication sharedApplication].keyWindow rootViewController]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM