LoginSignup
14
7

More than 5 years have passed since last update.

UnityでHTC Viveのダッシュボードの有効化/無効化

Posted at

HTC Viveで何か作ってるときにメニューボダンを押すとダッシュボードが出てきます。
ゲームしてる最中にダッシュボードが出て邪魔なので表示させない方法を調べたら

無題.png

SteamVRの設定で【VRダッシュボードを有効化】のチェックを外すと出てこなくなります。
自分ひとりならここのチェックを外すでよいのですが、アプリの説明にここのチェックを外してくださいは不親切なのでスクリプトでなんとかならないか調べました。

ということで、こんな感じ

using UnityEngine;

/// <summary>
/// HTC ViveのDashbordをdisableにする
/// </summary>
public class DashbordDisable : MonoBehaviour
{
    bool dashbordFlag;

    void Start()
    {
        dashbordFlag = GetDashboodEnabled();
        if (dashbordFlag)
        {
            SetDashboodEanbled(false);
        }
    }

    public void OnApplicationQuit()
    {
        if(dashbordFlag != GetDashboodEnabled())
        {
            SetDashboodEanbled(true);
        }
    }

    bool GetDashboodEnabled()
    {
        Valve.VR.EVRSettingsError er = new Valve.VR.EVRSettingsError();
        return Valve.VR.OpenVR.Settings.GetBool(Valve.VR.OpenVR.k_pch_Dashboard_Section, Valve.VR.OpenVR.k_pch_Dashboard_EnableDashboard_Bool, ref er);
    }

    void SetDashboodEanbled(bool flag)
    {
        Valve.VR.EVRSettingsError er = new Valve.VR.EVRSettingsError();
        Valve.VR.OpenVR.Settings.SetBool(
            Valve.VR.OpenVR.k_pch_Dashboard_Section, 
            Valve.VR.OpenVR.k_pch_Dashboard_EnableDashboard_Bool,
            flag, ref er
            );
        Valve.VR.OpenVR.Settings.Sync(false, ref er);
    }

}

コンポーネントを適当に貼り付ければ動きます

14
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
7