zoukankan      html  css  js  c++  java
  • 实操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"

    Android:configChanges="orientation|keyboardHidden|navigation|screenSize"
                            Android:theme="@Android:style/Theme.NoTitleBar.Fullscreen"
                            Android:windowSoftInputMode="adjustPan"
                            Android:windowBackground="@null"
                            Android:launchMode="singleTask"/>
    <ignore_js_op>
    <ignore_js_op>
     
    3.然后,在项目上右键RUN AS->Android APPLICATION。进入项目目录->bin文件夹->classes文件夹->复制里面所有的文件粘贴到一个找好的目录中,如JARU3D这个文件夹中。


    4打开终端,进入UARU3D这个文件夹,输入:jar -cvf myclass.jar *  回车,JARU3D文件夹中将多出:myclass.jar, 该文件做备用。
    <ignore_js_op>


    5.打开UNITY3D4.0,创建新UNITY项目后,在ASSETS文件夹下新建文件夹Plugins,在Plugins文件夹中新建Android文件夹,在Android文件夹中新建bin文件夹和libs文件夹,将myclass.jar复制到bin文件夹中,将91SDK的NdComPlatform.jar复制到libs文件夹中,将91SDK的res文件夹全部复制到Android文件夹中,将Android项目的AndroidManifest.xml复制到ANDORID文件夹下,把Android项目中的资源按照对应的文件夹复制到UNITY项目RES文件夹的对应文件夹内。
    在ASSETS文件夹中创建UNITY调用Android的文件,将该文件拖动到MAIN CAMERA放开鼠标进行绑定。


    <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 (3.77 MB, 下载次数: 1979) 
    UNITY3D4.0项目: <ignore_js_op> u3dprj.zip (2.92 MB, 下载次数: 1692) 
    UNTIYDEMO-APK包: <ignore_js_op> u3ddemo.apk.zip (9.68 MB, 下载次数: 4131) 
    ##SDK开发新做DEMO-----较新版本,非最新
    SDK3.2.6新DEMO: <ignore_js_op> Unity3d_91SDK_Demo.zip (17.63 MB, 下载次数: 15824) 

    2013-8-2 18:04 上传
    点击文件名下载附件
     




    注意: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.

  • 相关阅读:
    AE二次开发,解决子窗体使用父窗体的AxControl控件
    ArcEngine二次开发中运行出现There is no Spatial Analyst license currently available or enabled.
    Js网站开发学习第一天
    Winform开发1
    MySql安装
    Windows ping加时间戳
    XML特性总结
    linux手册中函数名后小括号中数字的含义
    TCP通信
    swap交换分区概念
  • 原文地址:https://www.cnblogs.com/123ing/p/3703692.html
Copyright © 2011-2022 走看看