{"id":96482,"date":"2020-04-18T23:00:25","date_gmt":"2020-04-18T15:00:25","guid":{"rendered":"http:\/\/4563.org\/?p=96482"},"modified":"2020-04-18T23:00:25","modified_gmt":"2020-04-18T15:00:25","slug":"%e5%a6%82%e4%bd%95%e5%b0%86-unity-%e4%bb%a5%e5%ba%93%e5%bd%a2%e5%bc%8f%e9%9b%86%e6%88%90%e5%88%b0%e5%8e%9f%e7%94%9f-ios-%e5%92%8c-android-%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=96482","title":{"rendered":"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : unn <\/span>  <span><i><\/i> 59<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u672c\u6587\u8f6c\u81ea Unity Connect<\/p>\n<p>\u4ece Unity 2019.3.a2 \u5f00\u59cb\uff0c\u6211\u4eec\u901a\u8fc7\u628a Unity \u8fd0\u884c\u65f6\u7ec4\u4ef6\u548c\u5185\u5bb9\u96c6\u6210\u5230\u539f\u751f\u5e73\u53f0\u9879\u76ee\uff0c\u5728\u539f\u751f\u5e94\u7528\u4e2d\u5c06 Unity \u4f5c\u4e3a\u5e93\u4f7f\u7528\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5206\u4eab\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\u3002\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u9605\u8bfb\uff1a\u300a\u5728\u539f\u751f iOS \u6216 Android \u5e94\u7528\u4e2d\u5c06 Unity \u4f5c\u4e3a\u5e93\u4f7f\u7528\u300b\u3002<\/p>\n<p>\u8bf7\u8bbf\u95ee\u4e91\u76d8\u4e0b\u8f7d\u793a\u4f8b\u9879\u76ee<\/p>\n<p>\u4e0b\u8f7d\u94fe\u63a5: https:\/\/pan.baidu.com\/s\/1JFWjbrh2x-qAsCzMwLywLA<\/p>\n<p>\u63d0\u53d6\u7801: 9a71<\/p>\n<p>iOS \u8bf7 iOS \u5f00\u53d1\u8005\u4f7f\u7528 Unity 2019.3.a2 \u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u4ee5\u53ca Xcode 9.4 \u53ca\u66f4\u9ad8\u7248\u672c\u3002<\/p>\n<p>\u4e0b\u8f7d Unity 2019.3.a2\uff1ahttps:\/\/unity3d.com\/alpha\/2019.3<\/p>\n<p><strong>1\u3001\u4e0b\u8f7d\u548c\u89e3\u538b\u9879\u76ee<\/strong><\/p>\n<p>\u6211\u4eec\u4f1a\u628a\u8be5 Unity \u9879\u76ee\u52a0\u5165\u5230\u539f\u751f iOS \u5e94\u7528\uff0cAssets\/Plugins\/iOS \u6587\u4ef6\u5939\u4e2d\u7684\u6587\u4ef6\u7528\u4e8e\u4f7f Unity \u64ad\u653e\u5668\u548c\u539f\u751f\u5e94\u7528\u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n<p>\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 Xcode \u5355\u89c6\u56fe\u5e94\u7528\uff0c\u8be5\u9879\u76ee\u62e5\u6709 UI\uff0c\u53ef\u4ee5\u4f7f\u7528 UnityFrameworkLoad()\u52a0\u8f7d\u64ad\u653e\u5668\u3002<\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u6211\u4eec\u628a\u4e8c\u4e2a\u9879\u76ee\u89e3\u538b\u5230\u76f8\u540c\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52df495873.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p><strong>2\u3001\u751f\u6210 iOS \u7684 Xcode \u9879\u76ee<\/strong><\/p>\n<p>\u6211\u4eec\u6309\u6b63\u5e38\u64cd\u4f5c\u751f\u6210 Xcode \u9879\u76ee\u5373\u53ef\u3002<\/p>\n<p>\u9996\u5148\u5728 Unity \u7f16\u8f91\u5668\u6253\u5f00 UnityProject \u9879\u76ee\uff0c\u9009\u62e9 Menu -&gt; Window -&gt; Package Manager\uff0c\u56e0\u4e3a 2.0.8 \u7248\u672c\u4e0d\u517c\u5bb9\u4f7f\u7528 Unity \u4f5c\u4e3a\u5e93\uff0c\u6240\u4ee5\u8981\u79fb\u9664 Ads \u8d44\u6e90\u5305\uff0c\u6216\u66f4\u65b0 Ads \u8d44\u6e90\u5305\u5230 v 3.*\u7248\u672c\u3002<\/p>\n<p>\u9009\u62e9 Menu -&gt; Edit -&gt; Player Settings -&gt; Player -&gt; iOS \u8bbe\u7f6e\u6807\u7b7e\u9875 -&gt; Identification Section\uff0c\u8bbe\u7f6e\u6709\u6548\u7684 Bundle Identification \u548c Signing Team ID\uff0c\u4ee5\u907f\u514d\u540e\u7eed\u6b65\u9aa4\u51fa\u73b0 Xcode \u7b7e\u540d\u95ee\u9898\u3002<\/p>\n<p>\u6253\u5f00 Menu -&gt; File -&gt; Builds Settings\uff0c\u5728\u6b64\u9009\u62e9\u5e76\u5207\u6362\u5e73\u53f0\u4e3a iOS\u3002\u5c06 UnityProject \u9879\u76ee\u6784\u5efa\u5230 iosBuild \u6587\u4ef6\u5939\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e01cfda0.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p><strong>3\u3001\u8bbe\u7f6e Xcode \u5de5\u4f5c\u7a7a\u95f4<\/strong><\/p>\n<p>Xcode \u5de5\u4f5c\u7a7a\u95f4\u5141\u8bb8\u540c\u65f6\u5904\u7406\u591a\u4e2a\u9879\u76ee\uff0c\u5e76\u7ed3\u5408\u5b83\u4eec\u7684\u7ed3\u679c\u3002 \u6211\u4eec\u5728 Xcode \u6253\u5f00 NativeiOSApp.xcodeproj\u3002\u9009\u62e9 File -&gt; New -&gt; Workspace\uff0c\u521b\u5efa\u5de5\u4f5c\u7a7a\u95f4\uff0c\u628a\u5b83\u4fdd\u5b58\u5728 UaaLExample\/both.xcworkspace\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e1092b9c.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u5173\u95ed NativeiOSApp.xcodeproj \u9879\u76ee\uff0c\u6b64\u540e\u7684\u6b65\u9aa4\u4f1a\u5728\u521a\u521b\u5efa\u7684\u5de5\u4f5c\u7a7a\u95f4\u9879\u76ee\u5b8c\u6210\u3002<\/p>\n<p>\u9009\u62e9 File -&gt; Add Files to \u201cboth\u201d\uff0c\u628a NativeiOSApp.xcodeproj \u548c\u7b2c 2 \u6b65\u751f\u6210\u7684 Unity-iPhone.xcodeproj \u6dfb\u52a0\u5230\u76f8\u540c\u7b49\u7ea7\u7684\u5de5\u4f5c\u7a7a\u95f4\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e297c4de.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p><strong>4\u3001\u6dfb\u52a0 UnityFramework.framework<\/strong><\/p>\n<p>\u6211\u4eec\u4ee5\u6846\u67b6\u7684\u5f62\u5f0f\u6dfb\u52a0 Unity \u64ad\u653e\u5668\u5230 NativeiOSApp\uff0c\u5b83\u76ee\u524d\u4e0d\u4f1a\u6539\u53d8 NativeiOSApp \u7684\u884c\u4e3a\u3002<\/p>\n<p>\u9996\u5148\u4ece NativeiOSApp \u9879\u76ee\u9009\u62e9 NativeiOSApp \u76ee\u6807\u3002\u5728 General -&gt; Embedded Binaries \u4e2d\u6309\u4e0b+\u6309\u94ae\u3002\u9009\u62e9 Unity-iPhone\/Products\/UnityFramework.framework\u3002<\/p>\n<p>\u6211\u4eec\u4ece Linked Frameworks and Libraries \u79fb\u9664 UnityFramework.framework\uff0c\u9009\u4e2d\u8be5\u6761\u76ee\u5e76\u6309\u4e0b-\u6309\u94ae\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e37220a0.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p><strong>5\u3001\u516c\u5f00 NativeCallProxy.h<\/strong><\/p>\n<p>\u539f\u751f\u5e94\u7528\u4f1a\u5b9e\u73b0\u4e0b\u9762\u6587\u4ef6\u5b9a\u4e49\u7684 NativeCallsProtocol\u3002<\/p>\n<p>\u9996\u5148\u627e\u5230\u5e76\u9009\u62e9 Unity-iPhone \/ Libraries \/ Plugins \/ iOS \/ NativeCallProxy.h\u3002<\/p>\n<p>\u7136\u540e\u5728 Target Membership \u4e2d\u52fe\u9009 UnityFramework\uff0c\u901a\u8fc7 UnityFramework \u53f3\u4fa7\u7684\u4e0b\u62c9\u56fe\u6807\uff0c\u628a\u6807\u5934\u53ef\u89c1\u6027\u8bbe\u4e3a Public\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e44d4444.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p><strong>6\u3001\u4f7f Data \u6587\u4ef6\u5939\u6210\u4e3a UnityFramework \u7684\u4e00\u90e8\u5206<\/strong><\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cData \u6587\u4ef6\u5939\u662f Unity-iPhone \u76ee\u6807\u7684\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u4f1a\u901a\u8fc7\u4fee\u6539\u5b83\uff0c\u4f7f\u6240\u6709\u5185\u5bb9\u5c01\u88c5\u5230\u5355\u4e2a\u6846\u67b6\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u6211\u4eec\u628a Data \u6587\u4ef6\u5939\u7684 Target Membership \u6539\u4e3a UnityFramework\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e53aace1.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u5728\u4e4b\u524d\u7684\u6539\u52a8\u540e\uff0c\u4e3a\u4e86\u4f7f Unity-iPhone \u9879\u76ee\u7ee7\u7eed\u5de5\u4f5c\uff0cUnity \u64ad\u653e\u5668\u9700\u8981\u901a\u8fc7\u4ece Unity-iPhone\/MainApp\/main.mm \u8fdb\u884c\u8c03\u7528\uff0c\u6307\u5411 Data \u6587\u4ef6\u5939\u6240\u5904\u7684\u65b0\u4f4d\u7f6e\u3002<\/p>\n<p>[ufw setDataBundleId: &#8220;com.unity3d.framework&#8221;];<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e0d\u652f\u6301\u6309\u9700\u4f7f\u7528\u8d44\u6e90\u3002\u4e3a\u4e86\u4f7f\u5b83\u4eec\u6b63\u5e38\u5de5\u4f5c\uff0c\u6211\u4eec\u4e0d\u4f1a\u4f7f\u7528\u524d\u9762\u7684\u8c03\u7528\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0b Data \u6587\u4ef6\u5939\u4f4d\u4e8e mainBundle\uff0c\u6240\u4ee5\u6211\u4eec\u8981\u590d\u5236 Data \u6587\u4ef6\u5939\u5230\u539f\u751f\u5e94\u7528\uff0c\u5e76\u8df3\u8fc7\u524d\u9762\u7684\u8c03\u7528\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e6311764.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u8fd0\u884c \u6240\u6709\u5185\u5bb9\u5df2\u7ecf\u51c6\u5907\u597d\u9488\u5bf9\u4e8c\u4e2a\u9879\u76ee\u8fdb\u884c\u6784\u5efa\uff0c\u8fd0\u884c\u548c\u8c03\u8bd5\uff0c\u5373\uff1aUnity-iPhone \u9879\u76ee\u548c NativeiOSApp \u9879\u76ee\uff0c\u9009\u62e9 Scheme \u4e3a NativeiOSApp \u6216 Unity-iPhone\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e70a6660.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd0\u884c NativeiOSApp\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e8055237.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u5b8c\u6574\u9879\u76ee\u8bf4\u660e \u5728\u96c6\u6210\u6b65\u9aa4\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u5df2\u7ecf\u51c6\u5907\u597d\u6784\u5efa\u548c\u90e8\u7f72\u7684\u5b8c\u6574\u9879\u76ee\uff0c\u53ea\u9700\u8981\u4fee\u590d Xcode \u7684\u7b7e\u540d\u5373\u53ef\u3002<\/p>\n<ul>\n<li>\n<p>NativeiOSApp \u76ee\u6807<\/p>\n<\/li>\n<li>\n<p>Unity-iPhone \u76ee\u6807\uff08\u53ef\u9009\uff09<\/p>\n<\/li>\n<li>\n<p>UnityFramework \u76ee\u6807\u4e0d\u9700\u8981\u7b7e\u540d<\/p>\n<\/li>\n<\/ul>\n<p>\u8bf7\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b8c\u6574\u9879\u76ee\u6587\u4ef6\uff0c\u5728 Xcode \u6253\u5f00 both.xcworkspace\uff0c\u8fd0\u884c NativeiOSApp Scheme\u3002<\/p>\n<p><strong>\u5173\u952e\u8981\u70b9<\/strong><\/p>\n<p>Unity \u64ad\u653e\u5668\u7531 UnityFramework \u5bf9\u8c61\u63a7\u5236\u3002\u4e3a\u4e86\u83b7\u53d6\u8be5\u5bf9\u8c61\uff0c\u6211\u4eec\u8981\u8c03\u7528 UnityFrameworkLoad\uff0c\u5b83\u4f1a\u52a0\u8f7d UnityFramework.framework\uff0c\u7136\u540e\u8fd4\u56de\u5355\u4e2a\u5b9e\u4f8b\u5230 UnityFramework \u7c7b\uff0c\u8bf7\u89c2\u5bdf Unity-iPhone\/UnityFramework\/UnityFramework.h\uff0c\u4e86\u89e3\u5b83\u7684 API\u3002<\/p>\n<p>\u8bf7\u5728 NativeiOSApp\/NativeiOSApp\/MainViewController.mm \u6587\u4ef6\u4e2d\u6216 Unity-iPhone\/MainApp\/main.mm \u6587\u4ef6\u4e2d\u89c2\u5bdf UnityFrameworkLoad\u3002<\/p>\n<pre><code> #include &lt;UnityFramework\/UnityFramework.h&gt;  UnityFramework* UnityFrameworkLoad() {     NSString* bundlePath = nil;     bundlePath = [[NSBundle mainBundle] bundlePath];     bundlePath = [bundlePath stringByAppendingString: @\"\/Frameworks\/UnityFramework.framework\"];      NSBundle* bundle = [NSBundle bundleWithPath: bundlePath];     if ([bundle isLoaded] == false) [bundle load];      UnityFramework* ufw = [bundle.principalClass getInstance];     if (![ufw appController])     {         \/\/ \u9996\u6b21\u521d\u59cb\u5316 Unity         [ufw setExecuteHeader: &amp;_mh_execute_header];             \/\/ \u540c\u6b65 Data \u6587\u4ef6\u5939\u7684 Target Membership \u8bbe\u7f6e         [ufw setDataBundleId: \"com.unity3d.framework\"]          }     return ufw; }  <\/code><\/pre>\n<p>Android<\/p>\n<p>\u8bf7 Android \u5f00\u53d1\u8005\u4f7f\u7528 Unity 2019.3.a2 \u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u4ee5\u53ca Android Studio 3.3.2 \u53ca\u66f4\u9ad8\u7248\u672c\u3002<\/p>\n<p><strong>1\u3001\u4e0b\u8f7d\u548c\u89e3\u538b\u9879\u76ee<\/strong><\/p>\n<p>\u8bf7\u4e0b\u8f7d Unity \u9879\u76ee\uff0c\u8be5\u9879\u76ee\u662f\u8981\u52a0\u5165\u539f\u751f Android \u5e94\u7528\u7684\u793a\u4f8b Assets\/Plugins\/Android \u6587\u4ef6\u5939\u4e2d\u6709\u6269\u5c55 UnityPlayerActivity \u7684 OverrideUnityActivity \u6587\u4ef6\u3002<\/p>\n<p>\u6211\u4eec\u63d0\u4f9b\u7684\u539f\u751f Android \u9879\u76ee\u662f\u6765\u81ea Android Studio \u6a21\u677f\u7684 Basic Activity \u5e94\u7528\u7a0b\u5e8f\uff0c\u6211\u4eec\u4f1a\u628a\u524d\u9762\u7684 Unity \u9879\u76ee\u52a0\u5165\u5230\u8fd9\u91cc\u3002\u8be5\u9879\u76ee\u6709 UI \u548c MainUnityActivity \u6765\u6269\u5c55 OverrideUnityActivity\uff0c\u53ef\u4ee5\u4f7f\u7528 Intent \u542f\u52a8 MainUnityActivity\u3002<\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u6211\u4eec\u628a\u4e8c\u4e2a\u9879\u76ee\u89e3\u538b\u5230\u76f8\u540c\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e8cd2a37.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p><strong>2\u3001\u751f\u6210 Android \u5e73\u53f0\u7684 Gradle \u9879\u76ee<\/strong><\/p>\n<p>\u6211\u4eec\u5728 Unity \u7f16\u8f91\u5668\u6253\u5f00 UnityProject \u9879\u76ee\uff0c\u70b9\u51fb Menu -&gt; File -&gt; Build Settings \u6253\u5f00 Build Settings\u3002<\/p>\n<p>\u9009\u62e9\u5e76\u5207\u6362\u4e3a Android Platform\uff0c\u52fe\u9009 Export Project \u9009\u9879\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52e9b82a1a.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u6211\u4eec\u628a UnityProject \u5bfc\u51fa\u5230 androidBuild \u6587\u4ef6\u5939\uff0c\u8be5\u6587\u4ef6\u5939\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52ea9dd896.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>3\u3001\u628a Unity Library \u6a21\u5757\u6dfb\u52a0\u5230 NativeAndroidApp<\/p>\n<p>\u73b0\u5728\u628a androidBuild\/unityLibrary \u6a21\u5757\u6dfb\u52a0\u7ed9 Android Studio \u4e2d\u7684 NativeAndroidApp Gradle \u9879\u76ee\uff1a<\/p>\n<p>\u6211\u4eec\u5728 Android Studio \u6253\u5f00 NativeAndroidApp\uff0c\u7136\u540e\u6253\u5f00 settings.gradle \u6587\u4ef6\u3002\u5728\u8be5\u6587\u4ef6\u672b\u5c3e\uff0c\u6dfb\u52a0\u6307\u5411 unityLibrary \u7684\u65b0\u9879\u76ee\u3002<\/p>\n<pre><code> include ':unityLibrary' project(':unityLibrary').projectDir=new File('..\\UnityProject\\androidBuild\\unityLibrary')  <\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52eb97599a.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u6253\u5f00 build.gradle \u6587\u4ef6\uff0c\u628a\u4e0b\u9762\u4ee3\u7801\u6dfb\u52a0\u5230 dependencies \u4ee3\u7801\u5757\u3002<\/p>\n<pre><code>implementation project(':unityLibrary')  <\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52ec52960a.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u6253\u5f00 build.gradle \u6587\u4ef6\uff0c\u628a\u4e0b\u9762\u4ee3\u7801\u6dfb\u52a0\u5230 allprojects{repositories{\u4ee3\u7801\u5757\u3002<\/p>\n<pre><code>flatDir {    dirs \"${project(':unityLibrary').projectDir}\/libs\" }  <\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52edfce0ec.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>Gradle \u6587\u4ef6\u5df2\u7ecf\u4fee\u6539\uff0c\u5355\u51fb Sync Now\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52ef004b0f.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6211\u4eec\u4f1a\u770b\u5230 unityLibrary \u6a21\u5757\u6dfb\u52a0\u5230 Android \u89c6\u56fe\u4e2d\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52efe35402.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u8fd0\u884c \u73b0\u5728\u5df2\u7ecf\u51c6\u5907\u597d\u8fdb\u884c\u6784\u5efa\uff0c\u8fd0\u884c\u548c\u8c03\u8bd5\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52f0cb6d32.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6211\u4eec\u5e94\u8be5\u53ef\u4ee5\u8fd0\u884c NativeAndroidApp\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200520_5ec52f1838e7c.png\" alt=\"\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\" \/><\/p>\n<p>\u8bf7\u6ce8\u610f\uff1a\u5728\u5e94\u7528\u7a0b\u5e8f\u5b89\u88c5\u5230\u8bbe\u5907\u540e\uff0c\u4f1a\u51fa\u73b0\u4e8c\u4e2a\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\u7684\u56fe\u6807\uff0c\u8bf7\u628a&lt;intent-filter&gt;&#8230;&lt;\/intent-filter&gt;\u4ece unityLibrary \u7684 AndroidManifest.xml \u53bb\u6389\uff0c\u4ec5\u4fdd\u7559\u96c6\u6210\u7248\u672c\u3002<\/p>\n<p><strong>\u5b8c\u6574\u9879\u76ee\u8bf4\u660e<\/strong><\/p>\n<p>\u5982\u679c\u5728\u96c6\u6210\u6b65\u9aa4\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u5df2\u7ecf\u51c6\u5907\u597d\u6784\u5efa\u548c\u90e8\u7f72\u7684\u5b8c\u6574\u9879\u76ee\u3002\u8bf7\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b8c\u6574\u9879\u76ee\u6587\u4ef6\uff0c\u5728 Android Studio \u6253\u5f00 NativeAndroidApp\u3002<\/p>\n<p>\u5c0f\u7ed3<\/p>\n<p>\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230\u539f\u751f iOS \u548c Android \u5e94\u7528\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5230\u8fd9\u91cc\uff0c\u8bf7\u4e0b\u8f7d\u793a\u4f8b\u9879\u76ee\u52a8\u624b\u64cd\u4f5c\u8d77\u6765\u5427\u3002<\/p>\n<p>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/connect.unity.com\/p\/ru-he-jiang-unityyi-ku-xing-shi-ji-cheng-dao-yuan-sheng-ioshe-androidying-yong?app=true \u66f4\u591a Unity \u5e72\u8d27\u8d44\u6e90\uff0c\u8bf7\u6233\u4e0a\u65b9\u94fe\u63a5\u4e0b\u8f7d Unity \u5b98\u65b9 app\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06 Unity \u4ee5\u5e93\u5f62\u5f0f\u96c6\u6210\u5230&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/96482"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=96482"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/96482\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=96482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=96482"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=96482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}