如何在 iOS 应用程序中添加 Unity 3d 的统一视图?

How to add Unity 3d's unity View in iOS app?

我想在我的申请中添加 Unity3d 项目的 UnityView

我已成功从 Unity 3d 导入项目并将其中的代码添加到我的应用程序中。

项目构建成功。但正如我们所知,项目中只有一个 main.m 文件。但是 UnityAppController.h 中的以下功能对我来说很困难。

inline UnityAppController*  GetAppController()
{
    return (UnityAppController*)[UIApplication sharedApplication].delegate;
}

每当我在 UnityAppController 上调用方法时,它会应用于 Appdelegate class, 所以我崩溃了 unrecognized selector sent to instance.

如果你们中的任何人对此有任何指导,请帮助我。

转到:- https://github.com/frederik-jacques/native-ios-and-unity3d

并导入 TNAppController.mm class.

createViewHierarchyImpl替换为

 -(void)willStartWithViewController:(UIViewController*)controller

将此行添加到 addView :

[self.view addSubview:GetAppController().unityView];

如果您仍然遇到问题,请告诉我。