Unity3D:是否可以查看Android和iPhone设备的音量? [英] Unity3D: is it possible to check the volume of both Android and iPhone devices?

查看:329
本文介绍了Unity3D:是否可以查看Android和iPhone设备的音量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

void Update(){
    GetComponent<UnityEngine.UI.Text> ().text = AudioListener.volume.ToString();
}

推送到我的Android设备后,当我按下Android的物理音量按钮时,它始终显示为"1".因此,它无法检测电话的实际容量.是否可以查看手机的当前音量?

After pushing to my Android device, it always says "1" when I push the physical volume buttons of the Android. So it is not detecting what the volume of the phone actually is. Is it possible to check the current volume of the phone?

我正在使用Google Cardboard SDK.这可能很重要,因为它可以同时使用多个摄像机.也许与权限有关?

I'm working with the Google Cardboard SDK. Maybe that's important as it uses several cameras at the same time. Maybe is it something related with permissions?

推荐答案

仅作记录,

这是一个很好的问题,您可以从Unity获取电话音量设置吗?

It's a great question, can you get the phone volume setting, from Unity?

首先:请注意,AudioListener.volume完全无关.这只是Unity认为用于播放音乐或声音效果的音量.

Firstly: do note that AudioListener.volume is totally unrelated. That is simply the volume as Unity thinks of it for your playing music or sound effects.

第二:恐怕要说,我很确定 没有办法 设置,从Unity开始,直到2016年.

Secondly: I'm afraid to say, I'm fairly sure there is no way to get the phone volume setting, from Unity, as of 2016.

如果有人更了解-回答!

If someone knows better - answer!

很好的问题.

更新(摘自评论)

注意.可以 可能 控制系统音量.但是OP必须为此编写本机插件.

Note. It is possibly possible to control system volume. But OP would have to write native plugins for that.

考虑以下质量检查:

  • For Android: How do you get/set media volume (not ringtone volume) in Android?
  • For iOS: iOS 9: How to change volume programmatically without showing system sound bar popup?

请注意,但是在iOS上更改音量(与Unity无关)是关于苹果是否在应用商店中批准的棘手问题.与Android相同.这些问题与Unity无关,并且在您阅读本文档的任何年份都需要有关应用程序商店,三星硬件等的知识.并且请注意,在许多有关更改电话音量"的质量检查中,关于更改应用程序中某些东西的音量与实际电话音量控制"的混淆再次出现.

Note however that changing the volume in iOS (nothing to do with Unity) is a tricky issue regarding whether Apple approve it on the app store. Same for Android. These issues are unrelated to Unity and require knowledge about the app store, Samsung hardware, etc, in whatever year you are reading this. AND note that in many QA about "changing volume" on phones, there is again simply confusion about changing the volume of something in an app versus "the actual phone volume control".

这篇关于Unity3D:是否可以查看Android和iPhone设备的音量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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