|
OC版Unity工程融合
1.更改app启动 删除main.storyboard 在app delegate中创建window并添加根控制器
2.在项目中创建Unity文件夹,将Unity中的Library和Native文件夹拖到项目的Unity文件夹下
3.remove references Libraries文件夹下的libel2cpp文件夹
4.remove references Classes/Native文件夹下所有的.h文件
5.将Data文件夹拖到Unity文件夹下,选择 Create folder references
6.添加framework
7.Build-Settings
7.1 Enable-Bitcode No
7.2 Other Linker Flags -weak_framework CoreMotion -weak-lSystem
7.3 Header Search Paths
7.4 Library Search Paths
7.5 Other C Flags
7.6 C Language Dialect
7.7 创建pch文件,并设置Prefix Header
7.8 Precompile Prefix Header YES
7.9 C++ Language Dialect
7.10 Enable C++ Runtime Types NO
7.11
7.12
7.13 Add User Difined
8. 将Classes文件夹下的pch的内容复制到自己的pch中 #import "UnityAppController.h"
9.将Supporting Files下的main.m文件后缀改成.mm 并将Classes文件夹下main.mm的内容复制(替换)一份到该main.mm中
10.main.mm中修改const char* AppControllerClassName = "AppDelegate";
11. 在Build Phases中的Compile Sources中删除Classes目录下的main.mm
12.在pch文件中添加 #import "UnityAppController.h"
13.在AppDelegate.h中添加
@property (nonatomic,strong)UnityAppController *unityController;
14.在AppDelegate.m中的didFinishLaunchingWithOptions方法中添加
self.unityController = [[UnityAppController alloc] init];
[self.unityController application:application didFinishLaunchingWithOptions:launchOptions];
并在所有对应的启动方法中添加
[self.unityController applicationWillResignActive:application];
[self.unityController applicationDidEnterBackground:application];
[self.unityController applicationWillEnterForeground:application];
[self.unityController applicationDidBecomeActive:application];
[self.unityController applicationWillTerminate:application];
15.修改UnityAppController.h文件中GetAppController的代码为
#import "AppDelegate.h"
inline UnityAppController* GetAppController()
{
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
return delegate.unityController;} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|