简体   繁体   English

如何在iOS应用中添加Unity 3d的unity View?

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

I want to add Unity3d project's UnityView in my application. 我想在我的应用程序中添加Unity3d项目的UnityView

I had succesfully imported project from Unity 3d & add code from it into my application. 我已经从Unity 3d成功导入了项目,并将代码从其中添加到了我的应用程序中。

Project builded succesfully. 项目成功建立。 But as we knew there will only one main.m file in project. 但是,正如我们所知,项目中只有一个main.m文件。 But below function in UnityAppController.h make difficulty for me. 但是在UnityAppController.h下面的函数给我UnityAppController.h困难。

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

Whenever i call method on UnityAppController its applied on Appdelegate class, so i get crash like unrecognized selector sent to instance . 每当我在UnityAppController上调用方法时, UnityAppController其应用于Appdelegate类,因此我会崩溃,就像unrecognized selector sent to instance

If any of you have any guidance for me regarding this then please help me. 如果您对我有任何指导,请帮助我。

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

and import TNAppController.mm class. 并导入TNAppController.mm类。

Replace createViewHierarchyImpl with createViewHierarchyImpl替换为

 -(void)willStartWithViewController:(UIViewController*)controller

Add this line to addView : 将此行添加到addView:

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

If you still facing issue then let me know. 如果您仍然遇到问题,请告诉我。

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

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