Unity中的Android Internet权限 [英] Android Internet permission in Unity

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

问题描述

默认情况下,Unity似乎不放置

It seems like by default Unity doesn't put

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

生成AndroidManifest.xml.这些权限在我的项目中是必需的. Google没有给我直接答案.有可能吗?

to generated AndroidManifest.xml. These permissions are required in my project. Google doesn't give me direct answer. Is it possible?

推荐答案

转到编辑-> 项目设置-> 播放器.选择Android,构建设置,将 Internet访问自动更改为要求.您不必这样做,因为当您使用任何网络API时,Unity都会自动执行.

Go to Edit->Project Settings -> Player. Select Android, Build Settings, Change Internet Access from Auto to Require. You don't have to do this because Unity will do for automatically when you use any network API.

如果这还不够,您可以手动修改Android AndroidManifest.

If that's not enough for you then you can modify the Android AndroidManifest by hand.

1 .打开Unity.只需 Android构建您的项目一次.不要关闭它.

1. Open Unity. Build your project for Android just once. Don't close it.

2 .转到您的项目目录.步骤1之后,Unity将创建一个名为 Temp 的新文件夹.在该 Temp 中,还有另一个名为 StagingArea 的文件夹.进入 StagingArea 文件夹,然后将名为 AndroidManifest.xml 的文件复制到计算机中的另一个文件夹中.修改/添加您自己的自定义权限,例如问题中的权限.

2. Go to your Project Directory. A new Folder called Temp will be created by Unity after step 1. Inside that Temp there is another Folder called StagingArea. Go into the StagingArea folder and copy a file called AndroidManifest.xml into another folder in your computer. Modify/Add your own custom permission like the ones in your question.

3 .现在,将修改后的 AndroidManifest.xml 文件移动到您的项目目录-> 资产-> 插件-> Android .如果插件 Android 文件夹没有退出,请创建它们.

3. Now move that modified AndroidManifest.xml file to Your Project Directory->Assets->Plugins->Android. If the Plugins and the Android Folders does not exit, create them.

享受!

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

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