- Home /
Getting mUnityPlayers view outside UnityPlayerNativeActivity
Hi, i try to get the height of the android keyboard so i created the following method inside UnityPlayerNativeActivity:
public int getKeyBoardHeight(){ Rect aRect = new Rect(); mUnityPlayer.getView().getWindowVisibleDisplayFrame(aRect); return aRect.height(); }
With that i get the visible height when the keyboard is open and substract it from screen height to have the keyboard height.
I want to know if it is possible to create a seperate class to do this so i don't have to change or extend the UnityPlayerNativeActivity?
Answer by liortal · Oct 12, 2014 at 08:41 PM
Unity allows you to define your own custom Activity for you game. It has to subclass UnityPlayerActivity (or UnityPlayerNativeActivity).
On that class, you can define utility methods that you need to access, and then you can call them directly from your script code.
For more information, see this link: http://docs.unity3d.com/Manual/PluginsForAndroid.html
Thanks for your answer, thats exactly what i have done but i want to know if it is possible to get the unity view without creating a subclass of the activity.
Your answer
Follow this Question
Related Questions
How to update the Unity part included into an android native application ? 0 Answers
Android native crash in Bluestacks on startup without usable backtrace 0 Answers
Google Featuring Requirement on Android Themes 1 Answer
using shared libraries generated by Android project in Unity 0 Answers
How to call a Android native class with implements from unity ? 1 Answer