Forum Discussion
CaptainNemo7
3 years agoExplorer
Oculus Interaction SDK scrolling with thumbstick
Hey currently with the interaction sdk I am able to scroll with a click and drag with the primary button. I have not been able to find a way to just scroll with the joystick. Has anyone been able to ...
Anton111111
1 year agoExpert Protege
My solution:
private bool _hovered = false;
private bool _scrolling = false;
private void Update()
{
if (_hovered || _scrolling)
{
var primary = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
var secondary = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
var range =
(secondary.y != 0)
? secondary.y
: (primary.y != 0)
? primary.y
: 0;
if (range != 0)
{
_scrolling = true;
_recyclableScrollRect.verticalNormalizedPosition += range * 0.03f;
}
else
{
_scrolling = false;
}
}
}RedShed
1 year agoExplorer
Anton111111 wrote:
My solution:
private bool _hovered = false;
private bool _scrolling = false;
private void Update()
{
if (_hovered || _scrolling)
{
var primary = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
var secondary = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
var range =
(secondary.y != 0)
? secondary.y
: (primary.y != 0)
? primary.y
: 0;
if (range != 0)
{
_scrolling = true;
_recyclableScrollRect.verticalNormalizedPosition += range * 0.03f;
}
else
{
_scrolling = false;
}
}
}
I think you could even add a * Time.deltaTime to the code to make the scrolling speed frame rate independent.
Something like this:
_recyclableScrollRect.verticalNormalizedPosition += range * 0.03f * Time.deltaTime;
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago