-
Notifications
You must be signed in to change notification settings - Fork 81
Setup Custom Input Bindings for SteamVR Input System
ChengNan Yang edited this page Nov 4, 2019
·
5 revisions
-
Step 1. Add new action set and actions in SteamVR Input window
-
After creating custom action set and actions, remember to Save and generate
-
-
Step 2. Bind custom action to controller
-
Click on Open Binding UI(Sometimes the page is blank) or go to SteamVR(top-left corner)>Devices>Controller Settings
-
Bind myaction to Trigger
-
-
Step 3. (METHOD 1) Create new action script
- For SteamVR Plugin v2.0.1, this version is quite buggy
- MUST add SteamVR_Behaviour.cs and SteamVR_ActivateActionSetOnLoad.cs
- For SteamVR Plugin v2.0.1, this version is quite buggy
using UnityEngine;
using Valve.VR;
public class MyActionScript : MonoBehaviour
{
public SteamVR_Action_Boolean myAction;
public SteamVR_Input_Sources handType;
void Update()
{
Debug.Log("Value GetState:" + myAction.GetState(handType));
Debug.Log("Value GetStateUp:" + myAction.GetStateUp(handType));
Debug.Log("Value GetStateDown:" + myAction.GetStateDown(handType));
}
}
-
Step 3. (METHOD 2) Create new action script
- For SteamVR Plugin v2.1.0 and above
- MUST add SteamVR_ActivateActionSetOnLoad.cs
- For SteamVR Plugin v2.1.0 and above
using UnityEngine;
using Valve.VR;
public class MyActionScript : MonoBehaviour
{
public SteamVR_Action_Boolean myAction;
public SteamVR_Input_Sources handType;
void Start()
{
myAction.AddOnStateDownListener(TriggerDown, handType);
myAction.AddOnStateUpListener(TriggerUp, handType);
}
public void TriggerUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
{
//TODO
}
public void TriggerDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
{
//TODO
}
void Update()
{
Debug.Log("Value GetState:" + myAction.GetState(handType));
Debug.Log("Value GetStateUp:" + myAction.GetStateUp(handType));
Debug.Log("Value GetStateDown:" + myAction.GetStateDown(handType));
}
}