概要
public int GetKeyboardSize()
{
#if !UNITY_EDITOR && UNITY_ANDROID
using ( var unityPlayer = new AndroidJavaClass( "com.unity3d.player.UnityPlayer" ) )
{
var view = unityPlayer
.GetStatic<AndroidJavaObject>( "currentActivity" )
.Get<AndroidJavaObject>( "mUnityPlayer" )
.Call<AndroidJavaObject>( "getView" )
;
using ( var rect = new AndroidJavaObject( "android.graphics.Rect" ) )
{
view.Call( "getWindowVisibleDisplayFrame", rect );
return Screen.height - rect.Call<int>( "height" );
}
}
#else
return 0;
#endif
}
参考サイト様