美文网首页
unity swift

unity swift

作者: 青春已给下一代 | 来源:发表于2020-05-06 14:58 被阅读0次

    1,拖过来注释main.mm main方法 并 替换在UnityAppController.h中替换inline方法 参考第11步

    NS_INLINE UnityAppController*GetAppController(){NSObject*delegate=[UIApplication sharedApplication].delegate;// 这里的@字符串 要和Appdelegate.swift中的变量名一致

        UnityAppController*currentUnityController=(UnityAppController*)[delegate valueForKey:@"unityController"];

        return currentUnityController;

    }

    注:拖入Classes 和  Libraries 以group的方式,确保为黄色文件夹

            拖入Data 以refrece的方式,确保为蓝色文件夹

    2,il2cpphstringreference.h 文件中的

    #include  <il2cpp-object-internals.h> 换成 #include "il2cpp-object-internals.h"

    3,devicesetting.mm  281 增加 return deviceUnknown;

    4,删除:DynamicLibEngineAPI-functions.h && DynamicLibEngineAPI.mm

    5,注释掉UnityAppController.mm中的327行 [self performSelector: @selector(startUnity:) withObject: application afterDelay: 0];

    以下为第一次

    1,在原有项目根目录下新建u3dReport(任意名字)

    2,拖入Classes 和  Libraries 以group的方式,确保为黄色文件夹

    3,拖入Data 以refrece的方式,确保为蓝色文件夹

    4,桥接文件和配置文件

        在https://github.com/blitzagency/ios-unity5 下载配置文件:

    UnityBridge.h 桥接文件修改版本号为unity版本

    5,如果没有则以下设置,如果有,把UnityBridge.h中拷贝到现有乔姐文件中

    6,设置Unity文件夹路径

    7,设置prefix文件路径

    8,添加头文件路径和库文件路径

    9、添加framework

    10、创建main.swift

    importFoundationimportUIKit// 这个方法名要和UnityUtils中的相同unity_init(CommandLine.argc,CommandLine.unsafeArgv)UIApplicationMain(CommandLine.argc,UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to:UnsafeMutablePointer<Int8>.self,capacity:Int(CommandLine.argc)),nil,NSStringFromClass(AppDelegate.self))

    11,6、其他文件修改

    找到Unity中的main.mm文件,注释main方法

    在UnityAppController.h中替换inline方法

    //替换为此方法NS_INLINE UnityAppController*GetAppController(){NSObject<UIApplicationDelegate>*delegate=[UIApplication sharedApplication].delegate;// 这里的@字符串 要和Appdelegate.swift中的变量名一致UnityAppController*currentUnityController=(UnityAppController*)[delegate valueForKey:@"unityController"];return currentUnityController;}

    12修改AppDelegate

    //@UIApplicationMainclassAppDelegate:UIResponder,UIApplicationDelegate{varwindow:UIWindow?varunityController:UnityAppController?funcapplication(_application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?)->Bool{// Override point for customization after application launch.unityController=UnityAppController()unityController?.application(application,didFinishLaunchingWithOptions:launchOptions)returntrue}funcapplicationWillResignActive(_application:UIApplication){unityController?.applicationWillResignActive(application)}funcapplicationDidEnterBackground(_application:UIApplication){unityController?.applicationDidEnterBackground(application)}funcapplicationWillEnterForeground(_application:UIApplication){unityController?.applicationWillEnterForeground(application)}funcapplicationDidBecomeActive(_application:UIApplication){unityController?.applicationDidBecomeActive(application)}funcapplicationWillTerminate(_application:UIApplication){unityController?.applicationWillTerminate(application)}}、

    13 配置以下flags

    相关文章

      网友评论

          本文标题:unity swift

          本文链接:https://www.haomeiwen.com/subject/fsqwghtx.html