Created
June 8, 2017 08:46
-
-
Save baba-s/f18ab57089be7ed9ca45da870e5ee6fd to your computer and use it in GitHub Desktop.
This file contains 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
using UnityEngine; | |
namespace Cham | |
{ | |
/// <summary> | |
/// ソフトウェアキーボードの表示領域を管理するクラス | |
/// </summary> | |
public static class SoftwareKeyboaryArea | |
{ | |
/// <summary> | |
/// 高さを返します | |
/// </summary> | |
public static int Height | |
{ | |
get | |
{ | |
#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 ( int )TouchScreenKeyboard.area.height; | |
#endif | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment