实操UNITY3D接入91SDK安卓版
原地址:http://bbs.18183.com/thread-149758-1-1.html
本文内容为创建UNITY3D接入91SDK的DEMO的具体操作过程。本人水平有限,UNITY3D与Android如何交互的技术请大家参看雨松的博客。
我的开发环境:
MAC系统, ECLIPSE,
UNITY4.0
开发过程:
1.准备要UNITY为交互Android自备的CLASS.JAR文件。
我的操作过程是:应用程序->UNTITY文件夹->UNITY->右键:显示包内容->CONTENTS文件夹->PLAYBACKENGINES文件夹->AndroidPlayer文件夹->BIN文件夹->CLASS.JAR【目录:/Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidPlayer/bin】复制出来备用。
2.新建Android项目,把CLASS.JAR复制到项目libs文件夹中,将91SDK的NdComPlatform.jar也复制到libs文件夹中,将
MainActivity extends UnityPlayerActivity
,将需要调用的安卓SDK方法写好。AndroidManifest.xml根据91SDK的要求进行配置。Android项目中不需要引入91SDK的RES文件。为修复Android4.0+系统转屏崩溃问题,在AndroidManifest.xml中所有的configChanges内增加"|screenSize"。
如:<activity
Android:name="com.nd.commplatform.activity.SNSLoginActivity"
<ignore_js_op>
6.UNITY打包为APK安装包进行DEMO效果测试。注意PLAYERSETTINGS配置中BUNDLE
IDENTIFIER要和Android项目的package相同。
<ignore_js_op>
<ignore_js_op>
7.大功告成,参看胜利成果。
<ignore_js_op>
< ignore_js_op>
##李工文中提及文件-----老版本
Android项目: <ignore_js_op> u3dandroid.zip
UNITY3D4.0项目: <ignore_js_op> u3dprj.zip
UNTIYDEMO-APK包: <ignore_js_op> u3ddemo.apk.zip
##SDK开发新做DEMO-----较新版本,非最新
SDK3.2.6新DEMO: <ignore_js_op> Unity3d_91SDK_Demo.zip
注意: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.