将 Unity 与 Eclipse 集成 - 如何遵循“官方”教程的说明?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9022207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:37:23  来源:igfitidea点击:

Integrating Unity with Eclipse - How to follow the "official" tutorial's instructions?

androideclipseunity3d

提问by mdelolmo

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.

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

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 StagingAreacopy 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 movethe assetfolder contents from the Library project to the "Activity" project. It has two subfolders, binand libs.

  5. I modify the generated Activity to extend UnityPlayerActivityand 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.

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

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

  3. 同样,我创建了一个 Android 项目,导入之前创建的 Android 库项目和classes.jar.

  4. asset从库项目文件夹的内容,以“活动”项目。它有两个子文件夹,binlibs.

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

  6. 将相应的行添加到 manifest,基本上是 Library 项目中的那些行。

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:

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

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: 1and 2. They seem to have succeded, so it is possible to achieve following those steps (or similar).

只是提一下......阅读这两个SO问题:12。他们似乎已经成功,因此可以按照这些步骤(或类似步骤)实现。

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

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

Has anybody experienced this issue? Any suggestion or alternative?

有没有人遇到过这个问题?有什么建议或替代方案吗?

Regards.

问候。

回答by sunadorer

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

对于任何遇到此问题的人来说,Unity3d 与 android eclipse 项目的集成在以前的版本 (3.5) 中被破坏了!

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

使用较新版本的 Unity(已成功通过 3.5.2 测试)按照以下步骤一切正常。

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\playeras mentioned in the Unity Forum.

如果要定义自己的 Activity 或在片段内使用 Unity,则可以直接使用 UnityPlayer 类。为此,您可以查看Unity 论坛中提到的[UNITY_INSTALLATION]\Editor\Data\PlaybackEngines\androidplayer\src\com\unity3d\player

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!

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

回答by stan

I'm facing same thing. found that some more qcar related stuff is needed on top of unity project integration. it's mainly linking Qcar libraries and modifying manifest activities. have a look here https://ar.qualcomm.at/arforums/showthread.php?t=1243

我面临同样的事情。发现在统一项目集成之上还需要一些与 qcar 相关的东西。它主要是链接 Qcar 库和修改清单活动。看看这里 https://ar.qualcomm.at/arforums/showthread.php?t=1243

However not helping to me much. still getting same error. a bit stuck with it.

然而对我帮助不大。仍然得到同样的错误。有点坚持。

回答by ThomasW

There is another page on SO asking this question. They claim to have obtained an answer on the qualcomm forums, different from the one above: Unable to find QCARWrapper

SO上还有另一个页面问这个问题。他们声称在高通论坛上得到了一个答案,与上面的不同:Unable to find QCARWrapper