Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Unity上からAndroidのステータスバーをいじる メモ

More than 5 years have passed since last update.

■Unity上からAndroidのステータスバーをいじる

class StatusBarChanger {
    private static int newStatusBarValue;

    public static void Show() {
        #if UNITY_ANDROID
            setStatusBarValue(2048); // WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
        #endif
    }

    public static void Hide() {
        #if UNITY_ANDROID
            setStatusBarValue(1024); // WindowManager.LayoutParams.FLAG_FULLSCREEN; change this to 0 if unsatisfied
        #endif
    }

    private static void setStatusBarValue(int value) {
        newStatusBarValue = value;
        using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
            using (var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) {
                activity.Call("runOnUiThread", new AndroidJavaRunnable(setStatusBarValueInThread));
            }
        }
    }

    private static void setStatusBarValueInThread() {
        #if UNITY_ANDROID
        using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
            using (var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) {
                using (var window = activity.Call<AndroidJavaObject>("getWindow")) {
                    window.Call("setFlags", newStatusBarValue, newStatusBarValue);
                }
            }
        }
        #endif
    }
}

■Androidネイティブプラグイン等の参考ページ

http://qiita.com/otmb/items/98a4472674a561d93900

http://qiita.com/Gazyu/items/68ef5f8e60500575932b

http://tasogare66.blog.fc2.com/blog-entry-66.html

http://wannabe-jellyfish.hatenablog.com/entry/2015/02/22/000923

http://wannabe-jellyfish.hatenablog.com/entry/2015/02/22/000923

satotin
仕事で分からん事の調査メモ その時に動いただけなので今はどうかわかりません LGTMとかハードル上がるんで辛い、いいね!で良かったのに
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away