在Android上使用音量按钮在Unity3d [英] Using volume buttons on Android in Unity3d

查看:1688
本文介绍了在Android上使用音量按钮在Unity3d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用音量按钮在Android上unity3d游戏。不幸的是我看不到关于任何量被映射为重点code,所以在我看来,这个功能是从Unity3d缺席。是否有这样做是比较隐蔽的方法是什么?有没有可能是一个办法来解决这个问题?这个应用程序是在音量按钮的preSS只需发送一个UDP包,因此无须与Unity3d应用程序本身进行交互。可能是一个后台进程,可以处理呢?我只是希望的道路上建议遵循我不想浪费时间找错了树,我的解决方案。在此先感谢!

I am attempting to use the volume buttons in a unity3d game on Android. Unfortunately I can't see anything pertaining to volume being mapped as a KeyCode, so it seems to me that this functionality is absent from Unity3d. Is there a method of doing this that is more hidden? Is there possibly a way to get around this? The application of this is to simply send a UDP packet upon the press of the volume button so it needs not interact with the Unity3d application itself. Possibly a background process that can deal with it? I simply want advice on the path to follow as I don't want to waste time barking up the wrong tree for my solution. Thanks in advance!

推荐答案

您可以建立您的应用程序作为一个机器人工作室/ eclipse项目并修改 UnityPlayerActivity (见< A HREF =htt​​p://docs.unity3d.com/Manual/PluginsForAndroid.html相对=nofollow>扩展UnityPlayerActivity的Java code )

You can build your app as an android studio/eclipse project and modify the UnityPlayerActivity (see: Extending the UnityPlayerActivity Java Code)

然后就可以使用音量键在本说明,以便回答:<一href=\"http://stackoverflow.com/questions/2874743/android-volume-buttons-used-in-my-application\">Android - 在我的应用程序使用音量按键

Then you can use the volume keys as described in this SO answer: Android - Volume Buttons used in my application

从活动交际的一个例子unity3d方面:

An example of comunication from activity to unity3d context:

UnityPlayer.UnitySendMessage("TheNameOfYourGameObject", "PublicMethodInThatGameObject", "StringArgument");


注意,已经有三星(不是谷歌)不接受某个应用他们的商店如果按钮行为已更改的传闻。


Note that there have been rumors of Samsung (not Google) not accepting an app to their stores if the button behaviour has changed.

此外,这将是很好UX,如果用户仍然能够改变你的应用程序的音量。

Also, it would be good UX, if the user will still be able to change the volume of your app.

这篇关于在Android上使用音量按钮在Unity3d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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