关于Unity4.6.1 和 ios 64bit

时间:2022-09-01 10:05:26

 最近苹果要求苹果的app们都要支持64位系统。所以Untiy也在忙着做64位的适配。为了不影响Unity 的开发者的产品上线计划,Unity 在2015年1月14日发布了第一个支持64位iOS的 Unity4.6公测版本。于是我就下了个Unity4.6.1f1,发现它根本不支持arm64。没错人家说的是“发布了第一个支持64位iOS的 Unity4.6公测版本”,而不是正式版,公测版本的命名大概是Unity4.6.1px这样的不是Unity4.6.1fx。所以……

        顺便说一下升级Unity4.6.1f1后对原来Xcode工程的影响。
        由于在之前用Unity4.5的时候,我们要接入许多第三方SDK,所以我们对UnityAppController.mm做了很多修改。升级到4.6.1f1后Build Xcode工程时如果直接Append会报错,大概是“IOS81……”“IOS82……”这样的错。
        我们需要对UnityAppController.mm做如下修改:
1.将UnityInitTrampoline函数修改为:

void UnityInitTrampoline()
{
#if ENABLE_CRASH_REPORT_SUBMISSION
 SubmitCrashReportsAsync();
#endif
 InitCrashHandling();

 _ios42orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"4.2" options: NSNumericSearch] != NSOrderedAscending;
 _ios43orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"4.3" options: NSNumericSearch] != NSOrderedAscending;
 _ios50orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"5.0" options: NSNumericSearch] != NSOrderedAscending;
 _ios60orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"6.0" options: NSNumericSearch] != NSOrderedAscending;
 _ios70orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"7.0" options: NSNumericSearch] != NSOrderedAscending;
 _ios80orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"8.0" options: NSNumericSearch] != NSOrderedAscending;
 _ios81orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"8.1" options: NSNumericSearch] != NSOrderedAscending;
 _ios82orNewer = [[[UIDevice currentDevice] systemVersion] compare: @"8.2" options: NSNumericSearch] != NSOrderedAscending;

 // Try writing to console and if it fails switch to NSLog logging
 fprintf(stdout, "\n");
 if (ftell(stdout) < 0)
  SetLogEntryHandler(LogToNSLogHandler);

    // Fix home directory environment variable.
    const char *newHomeDirectory = ([[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] UTF8String]);
    setenv("XDG_CONFIG_HOME", newHomeDirectory, 1);
    
 UnityInitJoysticks();
}


2.添加以下函数和变量

bool _ios81orNewer   = false;
bool _ios82orNewer   = false;

extern "C" const char* const* UnityFontDirs()
{
 static const char* const dirs[] = {
  "/System/Library/Fonts/Cache",  // before iOS 8.2
  "/System/Library/Fonts/AppFonts", // iOS 8.2
  "/System/Library/Fonts/Core",  // iOS 8.2
  "/System/Library/Fonts/Extra",  // iOS 8.2
  NULL
 };
 return dirs;
}


void AppController_SendMainViewControllerNotification(NSString* name)
{
 [[NSNotificationCenter defaultCenter] postNotificationName:name object:UnityGetGLViewController()];
}


如果还是不行,就不要append了,直接build一个新的Xcode工程。


http://m.blog.csdn.net/blog/mengfanye1991/43258417