unity 显示、隐藏Android导航栏

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

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

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

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

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

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

  

unity 显示、隐藏Android导航栏

上一篇:【webpack】webpack打包之后调试源码


下一篇:Mybatis里Mapper.xml加强