Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can SteamVR_Input_Sources.Any refresh other sources in same action? #1082

Open
REshyx opened this issue Mar 16, 2023 · 1 comment
Open

Comments

@REshyx
Copy link

REshyx commented Mar 16, 2023

I don't know if it is a bug, I called an action whose source is SteamVR_Input_Sources.Any, it returns true when I press down the key. When I call the same action in next frame with source: SteamVR_Input_Sources.RightHand. it also returns true.
My aim is to using the key to realize a two-level menu. but when pressing the key once,it directly enters the secondary menu. I am sure the two two calls of action with SteamVR_Input_Sources.Any and SteamVR_Input_Sources.RightHand are both true. "Any" does not refresh "RightHand".
But when I write a script like this:

using UnityEngine;
using Valve.VR;

public class  Script1 : MonoBehaviour
{
   public static SteamVR_Action_Boolean Function = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Function");
   // Update is called once per frame
   void Update()
   {
       if (Function.GetStateDown(SteamVR_Input_Sources.Any))
       {
           Debug.LogError("Any stateDown. frame:" + Time.frameCount);
       }
       else {
           Debug.Log("Not any stateDown. frame:" + Time.frameCount);
           if (Function.GetStateDown(SteamVR_Input_Sources.RightHand))
           {
               Debug.LogError("Left stateDown. frame:" + Time.frameCount);
           } 
       }
   }
}

The “Any” seems refresh the "RightHand", the log "Right stateDown. frame: XXX" is never logged;

@REshyx
Copy link
Author

REshyx commented Mar 16, 2023

In this case, two calls in different frame is both true:

using UnityEngine;
using Valve.VR;

public class  Script1 : MonoBehaviour
{
    bool alter=false;
    public static SteamVR_Action_Boolean Function = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Function");
    // Update is called once per frame
    void Update()
    {
        if (!alter)
        {
            if (Function.GetStateDown(SteamVR_Input_Sources.Any))
            {
                Debug.LogError("Any stateDown. frame:" + Time.frameCount);
                alter = true;
            }
            
        }
        else {
            if (Function.GetStateDown(SteamVR_Input_Sources.RightHand))
            {
                Debug.LogError("Right stateDown. frame:" + Time.frameCount);
            }
            else {
                Debug.Log("None");
            }
        }
    }
}

image

but in this, it is true and false:

using UnityEngine;
using Valve.VR;

public class  Script1 : MonoBehaviour
{
    bool alter=false;
    public static SteamVR_Action_Boolean Function = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Function");
    // Update is called once per frame
    void Update()
    {
        if (Function.GetStateDown(SteamVR_Input_Sources.Any))
        {
            Debug.LogError("Any stateDown. frame:" + Time.frameCount);
        }
        else
        {           
            if (Function.GetStateDown(SteamVR_Input_Sources.RightHand))
            {
                Debug.LogError("Right stateDown. frame:" + Time.frameCount);
            }
            else { 
                Debug.LogError("Right not stateDown. frame:" + Time.frameCount);
            }
        }
    }
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant