Created
July 31, 2015 05:26
-
-
Save GOROman/5f18ecd9efe840eb26c0 to your computer and use it in GitHub Desktop.
UnityのC#からAndroidのボリュームを変更する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SetAndroidVolume( int volume ) | |
{ | |
#if (UNITY_ANDROID && !UNITY_EDITOR) | |
int STREAM_MUSIC = 3; // Constant Value: 3 (0x00000003) | |
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
AndroidJavaObject ac = jc.GetStatic<AndroidJavaObject>("currentActivity"); | |
AndroidJavaObject am = ac.Call<AndroidJavaObject>("getSystemService", "audio"); | |
am.Call("setStreamVolume", STREAM_MUSIC, volume, 0); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
give me more マシな方法