开发过程: 1.准备要UNITY为交互Android自备的CLASS.JAR文件。 我的操作过程是:MAC系统的是在应用程序->UNTITY文件夹->UNITY->右键:显示包内容->CONTENTS文件夹->PLAYBACKENGINES文件夹->AndroidPlayer文件夹->BIN文件夹->CLASS.JAR【目录:/Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidPlayer/bin】复制出来备用。 (WINDOWS系统的在Unity\Editor\Data\PlaybackEngines\androidplayer\bin里面) 2.新建Android项目,把CLASS.JAR复制到项目libs文件夹中,按91SDK开发文档要求进行环境配置,将 MainActivity extends UnityPlayerActivity ,将需要调用的安卓SDK方法写好。AndroidManifest.xml根据91SDK的要求进行配置。
3.然后,在项目上右键RUN AS->Android APPLICATION。进入项目目录->bin文件夹->classes文件夹->复制里面所有的文件粘贴到一个找好的目录中,如JARU3D这个文件夹中。
4打开终端(命令行),进入UARU3D这个文件夹,输入:jar -cvf myclass.jar * 回车,JARU3D文件夹中将多出:myclass.jar, 该文件做备用。
5.打开UNITY3D4.0,创建新UNITY项目
后,在ASSETS文件夹下新建文件夹Plugins,在Plugins文件夹中新建Android文件夹,在Android文件夹中新建bin文件夹和libs文件夹,将myclass.jar复制到bin文件夹中,将91SDK的
libs文件夹下的
NdComPlatform.jar、
alipay_msp.jar、android-support-v4.jar
复制到libs文件夹中
,将91SDK的res文件夹全部复制到Android文件夹中,将Android项目的AndroidManifest.xml复制到ANDORID文件夹下,把Android项目中的资源按照对应的文件夹复制到UNITY项目RES文件夹的对应文件夹内。
在ASSETS文件夹中创建UNITY调用Android的文件,将该文件拖动到MAIN CAMERA放开鼠标进行绑定。
6.UNITY打包为APK安装包进行DEMO效果测试。注意PLAYERSETTINGS配置中BUNDLE IDENTIFIER要和Android项目的package相同。 7.大功告成,参看胜利成果。 91SDK3.3-iOS版本的UNITY3D接入参考:http://bbs.18183.com/thread-1312884-1-1.html,和安卓的一样,SDK3.3未发布,代码稍微改改就可以用在现有版本的SDK上。 注意:manifest.xml里面的SNSControlCenterActivity和SNSLoginActivity的属性应为Android:configChanges="orientation|keyboardHidden|navigation|screenSize", 否则可能造成转屏崩溃,具体原因查询GOOGLE ADNROID官方网站。摘抄原文: Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations. "screenSize" The current available screen size has changed. This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).Added in API level 13. |
sdk(安卓)
最新推荐文章于 2024-06-20 15:41:25 发布