将Unity与Eclipse集成 - 如何遵循“官方”教程的指示? [英] Integrating Unity with Eclipse - How to follow the "official" tutorial's instructions?

查看:201
本文介绍了将Unity与Eclipse集成 - 如何遵循“官方”教程的指示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了关于如何将面向Android的Unity3D项目集成到eclipse中的所有文档。我想要这样做的原因是能够在我自己的正常Android应用程序中调用Unity3D Activity。



嗯,我试图按照
使用我可以想象的所有组合,我做了以下操作:


  1. 我使用了Unity Android项目并构建它(在Unity
    IDE中),然后将 / Temp / StagingArea / 文件夹复制到另一个位置。


  2. 我创建了一个新的Android项目,使用现有来源的创建,
    设置 StagingArea 复制文件夹的位置。这将是
    的Android图书馆项目。在属性上检查是库 - >
    Android。


  3. 再次创建一个Android项目,导入先前创建的
    Android Library项目和 classes.jar


  4. 资源文件夹内容从库项目移动到
    活动项目。它有两个子文件夹, bin libs


  5. 我修改生成的Activity以扩展 UnityPlayerActivity
    删除setContent行onCreate方法。更改
    包以匹配Unity Player包ID。


  6. 将相应的行添加到清单中,基本上是
    的库项目。


所以所有的编译没有错误,我可以运行项目,显示启动屏幕,然后黑屏,正确播放我的Unity场景的声音。 logcat显示以下错误:

  01-26 16:51:46.415:D / dalvikvm(2299):试图加载lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38 
01-26 16:51:46.415:E / Unity(2299):无法找到QCARWrapper
01- 26 16:51:46.415:D / dalvikvm(2299):试图加载lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38
01-26 16:51:46.415: E / Unity(2299):无法找到QCARWrapper
01-26 16:51:46.415:D / dalvikvm(2299):试图加载lib /data/data/es.fundacionvf.unity.gps/lib/ libQCARWrapper.so 0x40515a38
01-26 16:51:46.415:E / Unity(2299):无法找到QCARWrapper
01-26 16:51:46.415:I / Unity(2299):StopQCAR
01-26 16:51:46.415:I / Unity(2299):UnityEngine.Debug:Internal_Log(Int32,String,Object)
01-26 16:51:46.415:I / Unity(2299) :UnityEngine.Debug:Log(Object)
01-26 16:51:46.415:I / Unity(2299):UnityEngine.MonoBehaviour:print(Object)
01-26 16:51:46.415: I / Unity(2299):TrackerBeh aviour:StopQCAR()
01-26 16:51:46.415:I / Unity(2299):TrackerBehaviour:OnApplicationPause(Boolean)
01-26 16:51:46.415:I / Unity(2299) :
01-26 16:51:46.415:I / Unity(2299):(文件名:/Applications/buildAgent/work/842f9557127e852/Runtime/Export/Generated/UnityEngineDebug.cpp行:34)
01-26 16:51:46.425:D / dalvikvm(2299):试图加载lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38
01-26 16:51: 46.425:E / Unity(2299):无法找到QCARWrapper
01-26 16:51:46.425:I / Unity(2299):DllNotFoundException:QCARWrapper
01-26 16:51:46.425:I / Unity(2299):at(wrapper managed-to-native)TrackerBehaviour:stopTracker()
01-26 16:51:46.425:I / Unity(2299):at TrackerBehaviour.StopQCAR()[0x00000] in < filename unknown>:0
01-26 16:51:46.425:I / Unity(2299):在TrackerBehaviour.OnApplicationPause(布尔暂停)[0x00000] in< filename unknown>:0

只是提到...读这两个SO q使用者: 1 2 。他们似乎已经成功了,所以可以实现以下步骤(或类似的)。



我还发现有用的 Unity3D论坛上的这个主题,它基本上以更清晰的方式描述了相同的过程。



有没有人遇到这个问题?任何建议或替代方案?



问候。

解决方案

在此之前,将Unity3d整合到Android eclipse项目中已经在之前的版本(3.5)中被破坏了!



使用较新版本的Unity(使用3.5.2成功测试)这些步骤,一切都可以正常工作



如果要定义自己的活动或在片段中使用Unity,可以直接使用UnityPlayer类。为此,您可以查看 Unity论坛。



  UnityPlayer mPlayer =新的UnityPlayer(getActivity()); //将你的活动对象放在这里
int glesMode = mPlayer.getSettings()。getInt(gles_mode,1);
boolean trueColor8888 = false;
mPlayer.init(glesMode,trueColor8888);

//获取视图 - 例如从片段方法onCreateView返回:
View view = mPlayer.getView();






更新:第一个链接不可用unity3d支持页面,但论坛条目也包含所有必需的步骤!


I have read all the documentation I found on how to integrate Unity3D projects targeted to Android into eclipse. The reason I want to do that is to be able to call the Unity3D Activity within my own "normal" Android application.

Well, I tried to follow the steps listed on this tutorial. Using all the combinations I can imagine, I did the following:

  1. I used the Unity Android project and built it (within the Unity IDE), then copied the /Temp/StagingArea/ folder to another location.

  2. I created a new Android project, using create from existing sources, setting the location of the StagingArea copy folder. This would be the Android Library Project. Check "is Library" on properties -> Android.

  3. Again, I create an Android project, import the previusly created Android Library project and classes.jar.

  4. I move the asset folder contents from the Library project to the "Activity" project. It has two subfolders, bin and libs.

  5. I modify the generated Activity to extend UnityPlayerActivity and remove the setContent line of the onCreate method. Change the package to match the Unity Player bundle id.

  6. Add the corresponding lines to manifest, basically those that are on the Library project.

So everything compiles without errors, and I can run the project, shows the splash screen, and then a black screen, playing the sounds of my Unity Scene correctly. The logcat reveals the following errors:

01-26 16:51:46.415: D/dalvikvm(2299): Trying to load lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38
01-26 16:51:46.415: E/Unity(2299): Unable to find QCARWrapper
01-26 16:51:46.415: D/dalvikvm(2299): Trying to load lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38
01-26 16:51:46.415: E/Unity(2299): Unable to find QCARWrapper
01-26 16:51:46.415: D/dalvikvm(2299): Trying to load lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38
01-26 16:51:46.415: E/Unity(2299): Unable to find QCARWrapper
01-26 16:51:46.415: I/Unity(2299): StopQCAR
01-26 16:51:46.415: I/Unity(2299): UnityEngine.Debug:Internal_Log(Int32, String, Object)
01-26 16:51:46.415: I/Unity(2299): UnityEngine.Debug:Log(Object)
01-26 16:51:46.415: I/Unity(2299): UnityEngine.MonoBehaviour:print(Object)
01-26 16:51:46.415: I/Unity(2299): TrackerBehaviour:StopQCAR()
01-26 16:51:46.415: I/Unity(2299): TrackerBehaviour:OnApplicationPause(Boolean)
01-26 16:51:46.415: I/Unity(2299):  
01-26 16:51:46.415: I/Unity(2299): (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/Export/Generated/UnityEngineDebug.cpp Line: 34)
01-26 16:51:46.425: D/dalvikvm(2299): Trying to load lib /data/data/es.fundacionvf.unity.gps/lib/libQCARWrapper.so 0x40515a38
01-26 16:51:46.425: E/Unity(2299): Unable to find QCARWrapper
01-26 16:51:46.425: I/Unity(2299): DllNotFoundException: QCARWrapper
01-26 16:51:46.425: I/Unity(2299):   at (wrapper managed-to-native) TrackerBehaviour:stopTracker ()
01-26 16:51:46.425: I/Unity(2299):   at TrackerBehaviour.StopQCAR () [0x00000] in <filename unknown>:0 
01-26 16:51:46.425: I/Unity(2299):   at TrackerBehaviour.OnApplicationPause (Boolean pause) [0x00000] in <filename unknown>:0 

Just to mention... read these two SO questions: 1 and 2. They seem to have succeded, so it is possible to achieve following those steps (or similar).

I also found useful this topic on the Unity3D forum, which basically describes the same proccess in a clearer way.

Has anybody experienced this issue? Any suggestion or alternative?

Regards.

解决方案

For anyone stumbling across this, the integration of Unity3d into an android eclipse project was broken in the previous version (3.5)!

Using a newer version of Unity (successfully tested with 3.5.2) everything works fine again following these steps.

If you want to define your own activity or use Unity inside a fragment, you can use the UnityPlayer class directly. To do so you can have a look at [UNITY_INSTALLATION]\Editor\Data\PlaybackEngines\androidplayer\src\com\unity3d\player as mentioned in the Unity Forum.

Or just try this code that worked for us:

    UnityPlayer mPlayer = new UnityPlayer(getActivity()); // Put your activity object here
    int glesMode = mPlayer.getSettings().getInt("gles_mode", 1);
    boolean trueColor8888 = false;
    mPlayer.init(glesMode, trueColor8888);

    // Get the view - e.g. to return from the fragment method onCreateView:
    View view = mPlayer.getView();


Update: The first link is not available on the unity3d support page anymore, but the forum entry contains all needed steps too!

这篇关于将Unity与Eclipse集成 - 如何遵循“官方”教程的指示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆