首页投稿(暂停使用,暂停投稿)

【Vuforia】Unity导出项目迁移到Xcode

2016-08-03  本文已影响647人  HoyaWhite

版本说明:Xcode版本7.3.1 Unity版本5.3.5f1
Xcode_Unity_Version

最近发现做AR、VR在迁移项目时候遇到开启摄像头黑屏的问题,后来我在研究过程中发现,从UIApplicationMain启动Unity导出的UnityAppController是不会在开启摄像头时出现黑屏,又因为如果把Unity集成进公司项目的话,Unity其实是不会关闭的,只是主Window的显示问题,因此可以用两个独立的Window通过设置hidden属性解决这个问题。。。。。下面给出集成步骤->


1. 拷贝Unity导出Xcode项目中ClassesDataLibrariesMapFileParserMapFileParser.sh文件或文件夹到想要集成的项目中

注意:拷贝到对应项目的根目录中(跟.xcodeproj同级)

拷贝文件
2. 把其中的四个文件夹拖到项目中

注意:Data要选择Create folder references,另外在/Data/Raw/QCAR路径下的QCAR文件夹也要选择Create folder references,ClassesLibraries选择Create groups

`Data`
`Classes` and `Libraries`
目录结构
PS:不要破坏文件路径,Unity和FrameWorks文件夹是为了方便查看目录创建的非实体文件夹(New Group)
3. 提前编译
Build Phases
AudioToolbox.framework
AVFoundation.framework
CFNetwork.framework
CoreText.framework     
CoreGraphics.framework
Corelocation.framework
CoreMedia.framework
CoreMotion.framework
CoreVideo.framework
OpenAL.framework
OpenGLES.framework
iAd.framework
MediaPlayer.framework
QuartzCore.framework
SystemConfiguration.framework
libiconv.2.tbd
Link Binary With Libraries
4. 编译设置
Build Setting Enable Bitcode
5. 文件修改
//添加返回按钮
    CGFloat height = 50;
    CGFloat width = 100;
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - height, width, height)];
    [btn setBackgroundColor:[UIColor redColor]];
    [btn setTitle:@"返回" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(unityHidden) forControlEvents:UIControlEventTouchUpInside];
    [self.unityView addSubview:btn];
    
    self.wpDelegate = [[AppDelegate alloc] init];
    [self.wpDelegate application:application didFinishLaunchingWithOptions:launchOptions];
    
    [self unityHidden];
//实现方法
- (void)unityShow{
    self.wpDelegate.window.hidden = YES;
    [self.window makeKeyAndVisible];
}

- (void)unityHidden{
    self.window.hidden = YES;
    [self.wpDelegate.window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    RedVC *red = [[RedVC alloc] init];
    BlueVC *blue = [[BlueVC alloc] init];
    
    UINavigationController *navRed = [[UINavigationController alloc] initWithRootViewController:red];
    UINavigationController *navBlue = [[UINavigationController alloc] initWithRootViewController:blue];
    
    UITabBarController *tab = [[UITabBarController alloc] init];
    [tab addChildViewController:navRed];
    [tab addChildViewController:navBlue];
    
    self.window.rootViewController = tab;
    return YES;
}
6. 补充说明:
eg:在红色VC中监听屏幕点击跳转unity
上一篇下一篇

猜你喜欢

热点阅读