Xcode:
Unity:
1.导入文件 到项目根目录中(注意导入方式)
2.配置Build Phases
(1)添加Run Script:(
"$PROJECT_DIR/MapFileParser.sh"
rm -rf "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data/Raw/QCAR"
)
(2)添加Copy Files:
(3)添加framework:
3.配置Build Setting:
(1)
(2)Linking下(-lc++,$(inherited),-weak_framework,CoreMotion,-weak-lSystem,-ObjC)一定要按顺序来!!!
(3)Search Paths下
Framework:$(inherited),$(PROJECT_DIR)/Frameworks,$(PROJECT_DIR)
Header:$(inherited),$(SRCROOT)/Libraries/bdwgc/include,$(SRCROOT)/Classes/Native,$(SRCROOT),$(SRCROOT)/Classes,$(SRCROOT)/Libraries,$(SRCROOT)/Libraries/libil2cpp/include
Library:$(inherited),$(PROJECT_DIR)/Libraries,$(SRCROOT)/Libraries,$(SRCROOT)
(4)
C:-DINIT_SCRIPTING_BACKEND=1,$(inherited),-fno-strict-overflow,-DRUNTIME_IL2CPP=1
c++:$(OTHER_CFLAGS),$(inherited)
(5)下
不要选,c99不支持__weak,typeof这样的语法
(6)
version写unity版本,unity生成的工程里copy过来就行
3.配置项目
1.原生xcode中main.m改为main.mm(双击修改就行),并把Classes/main.mm全部copy过来,然后修改UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String: AppControllerClassName]);为return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));最后删掉Classes/main.mm(删除方式:Move to Trash)
2.Classes/Prefix.pch内容全部copy到自己的pch中,并删掉(删除方式:Move to Trash)
3.删除Libraries/libil2cpp文件夹(删除方式:Remove References)
最后
AppDelegate.h:
AppDelegate.m:
调用:
AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate showUnityWindow];
****************************************
修改Classes/Unity/DeviceSettings.mm/extern "C" int ParseDeviceGeneration(const char* model)方法最后一段