Gradle对Unity的依赖 [英] Gradle dependencies on Unity

查看:572
本文介绍了Gradle对Unity的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用估算信标创建了一个Android Studio项目.这要求修改build.gradle,以便它可以访问estimote sdk.我创建了该项目,并且效果很好.我还创建了一个简单的android插件来显示来自Unity的Toast消息(说明可在此处找到:

I recently created an Android Studio project using estimote beacons. This requires that the build.gradle be modified so that it can access the estimote sdk. I created the project and it works great. I also created a simple android plugin to show a Toast message from Unity (instructions found here: https://www.thepolyglotdeveloper.com/2014/06/creating-an-android-java-plugin-for-unity3d/).

现在,因为我们在工作中使用unity来创建应用程序,所以现在我需要为在beacons内使用的信标创建一个插件,我的问题基本上是,如何添加gradle依赖项(编译'com.estimote :sdk:0.9.7@aar')放入Android的图书​​馆项目(对于我所看到的图书馆项目,不会生成gradle文件)和/或变成统一的,以便我可以统一使用信标代码?

Now, because we use unity at my job to create apps, now I need to create a plugin for the beacons to be used inside unity, my question is basically, how do I add the gradle dependencies (compile 'com.estimote:sdk:0.9.7@aar') into the library project of Android (a library project, for what I saw, generates no gradle files) and/or into unity so that I can use the beacon code in unity?

推荐答案

我建议您看看

I recommend you take a look at the Unity Jar Resolver project by Google. It does something similar to what adding dependencies in Gradle does. Once you have it integrated, you would then create a class based on SampleDependencies.cs.

  1. SampleDependencies.cs从jar解析器复制到编辑器"文件夹
  2. 将文件和类重命名为更有用的名称,例如. "MyDependencies.cs"
  3. 取消对课程正文的注释
  4. 添加依赖项:svcSupport.DependOn("com.estimote", "sdk", "0.9.7");
  1. Copy SampleDependencies.cs from the jar resolver into an Editor folder
  2. Rename the file and class to be something more useful, eg. "MyDependencies.cs"
  3. Uncomment the body of the class
  4. Add your dependency: svcSupport.DependOn("com.estimote", "sdk", "0.9.7");

默认情况下,Jar Resolver将自动运行,将.aar文件复制到项目中.您可以将其关闭,只需在资产> Google Play服务>设置"中手动进行即可

By default, the Jar Resolver will run automatically, copying the .aar file into the project. You can turn this off and just do it manually in "Assets > Google Play Services > Settings"

注意:之所以称为Google Play服务,是因为它用于将Google Play服务和Firebase .aar文件导入Unity项目.它应该与其他依赖项一起使用,但是如果找不到源文件.aar file,则可能需要摆弄一些内部代码或文件系统放置.据我所知,它会在ANDROID_HOME/extras/*/m2respository目录中查找它们.

Note: It's called Google Play Services because it's used to import Google Play Services and Firebase .aar files into Unity projects. It should work with other dependencies, but you may need to finagle with some internal code or file system placement if it can't find the source .aar file. From what I can tell, it looks for them in ANDROID_HOME/extras/*/m2respository directories.

这篇关于Gradle对Unity的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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