if(device.TryGetFeatureValue(CommonUsages.secondaryButton, out bool isPressed))
This is linked to a canvas gameobject to be set active / unactive but it seems every frame it will be set unactive and then active and whatever it lands on when you release the button is the result. What should I do?
You should keep track yourself if the button was down on the previous frame, and then change your if-logic to “if the button is pressed now and was not pressed last frame”.
No, that would never me true. Something like this (pseudocode)
device.TryGetFeatureValue(CommonUsages.secondaryButton, out bool isPressed);
if (isPressed && !wasPressed) {
// button was *just* pressed, so do stuff
}
wasPressed = isPressed;