I have created one Unity basic game and take a build for Android and its working well but once I was trying to take build for Xcode then some issues are coming. basically I was trying to take some task from Volume up and Volume down key in an iOS.
I will show Android Code for Unity, help me with iOS code.
____________________________________________________________________
public int GetVolume()
{
if (Application.platform == RuntimePlatform.Android)
{
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject context = up.GetStatic("currentActivity");
AndroidJavaClass audioManagerClass = new
AndroidJavaClass("android.media.AudioManager");
AndroidJavaClass contextClass = new AndroidJavaClass("android.content.Context");
int AudioManager_STREAM_MUSIC = audioManagerClass.GetStatic("STREAM_MUSIC");
string Context_AUDIO_SERVICE = contextClass.GetStatic("AUDIO_SERVICE");
AndroidJavaObject audioService = context.Call("getSystemService", Context_AUDIO_SERVICE);
return audioService.Call("getStreamVolume", AudioManager_STREAM_MUSIC);
}
return 0;
}
↧