Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Custom Bindings with Vive Steam VR not working on build

Discussion in 'VR' started by adreamvoyager_unity, Oct 16, 2018.

  1. adreamvoyager_unity

    adreamvoyager_unity

    Joined:
    Oct 16, 2018
    Posts:
    14
    Hi Everyone,

    I have been working on a steam VR game, and I ran into an issue. I am creating a custom key bind for the HTC Vive control to hand the UP, DOWN, LEFT, and RIGHT press on the control pad.

    Everything works fine in the Unity Editor however whenever I build the project, the default controls work (such as teleport, grip, etc), but the custom controls do not work.

    I tried two different methods to get everything to work. Both work in the editor, but neither work whenever I build the project.

    I highlighted the area that accesses the custom bindings in Red. If anyone has a suggestion, I'd appreciate it.

    Thanks,

    -Gabe





    Here is the current bit of code I wrote for the object


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


    public enum controlPressType { Grip, Pinch, Up, Down, Left, Right };


    namespace Valve.VR.InteractionSystem.Sample
    {

    [RequireComponent(typeof(Interactable))]
    public class interactiveObject : MonoBehaviour
    {

    public SteamVR_Input_Sources thisHand;

    Interactable interactable;

    [EnumFlags]
    [Tooltip("The flags used to attach this object to the hand.")]
    public Hand.AttachmentFlags attachmentFlags = Hand.AttachmentFlags.ParentToHand | Hand.AttachmentFlags.DetachFromOtherHand | Hand.AttachmentFlags.TurnOnKinematic;

    [SteamVR_DefaultAction("Up", "default")]
    public SteamVR_Action_Boolean upAction;

    [SteamVR_DefaultAction("Down", "default")]
    public SteamVR_Action_Boolean downAction;

    [SteamVR_DefaultAction("Left", "default")]
    public SteamVR_Action_Boolean leftAction;

    [SteamVR_DefaultAction("Right", "default")]
    public SteamVR_Action_Boolean rightAction;


    public controlPressType ButtonToReleaseFromHand = controlPressType.Grip;

    public bool setRotationOnGrab = false;

    public Vector3 grabRotation;

    public bool setOffsetOnGrab = false;
    public Vector3 grabOffset;

    public GameObject instructionsPrefab;

    public string pinchLabel, gripLabel, upLabel, downLabel, leftLabel, rightLabel;

    //Events to trigger on different Situations
    public UnityEvent OnPinchHold, OnPinchRelease, OnGripHold, OnGripRelease, onDownPress, onDownRelease, onLeftPress, onLeftRelease, onRightPress, onRightRelease, onUpPressed, onUpReleased;




    bool upPressed = false, downPressed = false, leftPressed = false, rightPressed = false;


    private void Awake()
    {
    interactable = this.GetComponent<Interactable>();
    }

    // Use this for initialization
    void Start()
    {
    if (instructionsPrefab != null)
    {
    instructionsPrefab = Instantiate(instructionsPrefab, transform.position, transform.rotation);
    instructionsPrefab.SetActive(false);
    }
    }

    // Update is called once per frame
    void Update()
    {

    }


    private void OnHandHoverBegin(Hand hand)
    {
    //Debug.Log("Remote Hover");
    }


    protected virtual void HandHoverUpdate(Hand hand)
    {








    GrabTypes startingGrabType = hand.GetGrabStarting();

    if (startingGrabType == GrabTypes.Pinch)
    {



    hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
    gameObject.transform.position = hand.transform.position;
    hand.HideGrabHint();



    Transform t = hand.currentAttachedObject.transform;
    t.localEulerAngles = grabRotation;
    t.localPosition += grabOffset;


    if (instructionsPrefab != null)
    {
    instructionsPrefab.transform.rotation = hand.transform.rotation;
    instructionsPrefab.transform.position = hand.transform.position;
    instructionsPrefab.transform.SetParent(hand.transform, true);
    instructionsPrefab.SetActive(true);
    instructionsPrefab.GetComponent<instructionDiagramController>().setLabels(pinchLabel, gripLabel, upLabel, downLabel, leftLabel, rightLabel);
    instructionsPrefab.GetComponent<instructionDiagramController>().showDiagram();
    }


    }
    }


    protected virtual void HandAttachedUpdate(Hand hand)
    {


    GrabTypes currentGrabType = hand.GetGrabStarting();
    GrabTypes endGrabType = hand.GetGrabEnding();


    //if press the side grip release the object
    if (currentGrabType == GrabTypes.Grip)
    {


    if (ButtonToReleaseFromHand == controlPressType.Grip)
    {
    hand.DetachObject(gameObject, true);
    if (instructionsPrefab != null)
    instructionsPrefab.SetActive(false);
    }
    OnGripHold.Invoke();
    Debug.Log("Grip Pressed");


    }

    if (endGrabType == GrabTypes.Grip)
    {


    //releaseGrip(hand);
    OnGripRelease.Invoke();


    }

    //if PinchButtonIsPressed
    if (currentGrabType == GrabTypes.Pinch)
    {

    if (ButtonToReleaseFromHand == controlPressType.Pinch)
    {
    hand.DetachObject(gameObject, true);
    if (instructionsPrefab != null)
    instructionsPrefab.SetActive(false);
    }
    OnPinchHold.Invoke();

    }

    if (endGrabType == GrabTypes.Pinch)
    {

    OnPinchRelease.Invoke();

    }

    //if up button is pressed
    if (!upPressed)
    {
    //if (upAction.GetState(hand.handType))
    if (SteamVR_Input._default.inActions.Up.GetStateUp(thisHand))
    {
    Debug.Log("Up Pressed");
    upPressed = true;
    onUpPressed.Invoke();
    if (ButtonToReleaseFromHand == controlPressType.Up)
    releaseGrip(hand);

    }

    }
    else
    {
    //if (!upAction.GetState(hand.handType))
    if (SteamVR_Input._default.inActions.Up.GetStateDown(thisHand))
    {

    upPressed = false;
    onUpReleased.Invoke();

    }


    }

    //if down button is pressed
    if (!downPressed)
    {
    //if (downAction.GetState(hand.handType))
    if (SteamVR_Input._default.inActions.Down.GetStateDown(thisHand))
    {
    downPressed = true;
    onDownPress.Invoke();
    if (ButtonToReleaseFromHand == controlPressType.Down)
    releaseGrip(hand);
    }



    }
    else
    {
    //if (!downAction.GetState(hand.handType))
    if (SteamVR_Input._default.inActions.Down.GetStateUp(thisHand))
    {

    downPressed = false;
    onDownRelease.Invoke();

    }


    }

    //if left button is pressed
    if (!leftPressed)
    {
    if (leftAction.GetState(hand.handType))
    {
    leftPressed = true;
    onLeftPress.Invoke();
    if (ButtonToReleaseFromHand == controlPressType.Left)
    releaseGrip(hand);

    }

    }
    else
    {
    if (!leftAction.GetState(hand.handType))
    {

    leftPressed = false;
    onLeftRelease.Invoke();

    }

    }

    //if right button is pressed
    if (!rightPressed)
    {
    if (rightAction.GetState(hand.handType))
    {
    rightPressed = true;
    onRightPress.Invoke();
    if (ButtonToReleaseFromHand == controlPressType.Right)
    releaseGrip(hand);

    }

    }
    else
    {
    if (!rightAction.GetState(hand.handType))
    {
    rightPressed = false;
    onRightRelease.Invoke();
    }

    }


    //rotate weapon trigger to hand gesture





    }



    public void releaseGrip(Hand hand)
    {
    hand.DetachObject(gameObject, true);
    if (instructionsPrefab != null)
    instructionsPrefab.SetActive(false);

    }





    }

    }
     
  2. cocapasteque

    cocapasteque

    Joined:
    Sep 30, 2016
    Posts:
    20
    Same problem here, removed the old binding for the trackpad used as button and replaced it with "used as trackpad" binding so I can access the position of the thumb on the trackpad.
    It works in editor, in build you have to manually go to the bindings settings in SteamVR and manually reassign them.

    Could be nice to have an option to ship the controllers binding with the built application. Can't really find a way to do it...
     
  3. jurriensteenkamp

    jurriensteenkamp

    Joined:
    Dec 14, 2017
    Posts:
    1
    Any updates on this i am running in the same issues.
     
  4. eron82

    eron82

    Joined:
    Mar 10, 2017
    Posts:
    83
    When i publish the game and i run it on Steam i have the message “steam action manifest not found” and controller buttons don’t work. But if i run the game directly in the folder it works well.
     
  5. HipNGroovy

    HipNGroovy

    Joined:
    Apr 25, 2020
    Posts:
    2
    I had the same problem, and got this working by starting with a blank/default controller binding, and making sure to save my customizations with "Replace Default Binding".