unity 显示、隐藏Android导航栏

1、下面的返回、home栏可用Screen.fullScreen控制

2、导航栏的显示和隐藏用下面代码控制

 private AndroidJavaObject currentActivity
    {
        get
        {
            return new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity");
        }
    }

    /// 
    ///  隐藏上方状态栏
    /// 
    public void HideStatusBar()
    {
#if UNITY_ANDROID
        currentActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
        {
            currentActivity.Call("getWindow").Call("clearFlags", 2048);

        }));
#endif
        Debug.Log("hide status bar");
    }

    /// 
    ///  显示上方状态栏
    /// 
    public void ShowStatusBar()
    {
#if UNITY_ANDROID
        currentActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
        {
            currentActivity.Call("getWindow").Call("addFlags", 2048);// WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
        }));
#endif
        Debug.Log("show status bar");
    }

  

3、

using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public class AndroidInterface
{

    private static AndroidInterface instance;
    public static AndroidInterface Instance {
        get {
            if (instance==null)
            {
                instance = new AndroidInterface();
            }
            return instance;
        }
    }
    private AndroidInterface() { }

    private AndroidJavaObject currentActivity
    {
        get
        {
            return new AndroidJavaClass

你可能感兴趣的:(游戏,移动开发,java)