09-29-2022 11:56 AM
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 fix this/find this?
09-29-2022 05:12 PM
Interaction SDK is broken with most of UI elements. InputFields are not working at all since v41
10-03-2022 11:26 AM
how are you or others getting around this?
04-05-2024 01:16 PM
I was actually quite close to implementing a feature for scrolling via thumbstick, but ultimately decided against it, since it doesn't really fit into my app.
But in a nutshell, that's how I would do it (in pseudocode):
1. Create a script and attach it to a scrolview.
2. OnPointerEnter -> triggerStays = true;
3. OnPointerExit -> triggerStays = false;
(For detecting whether you are currently pointing at the viewport)
4. Void update() -> if triggerStays = true execute following code:
var thumbstickposition = OVRInput.getThumbstickposition;
scrollRect.verticalNormalizedPosition = scrollRect.verticalNormalizedPosition + ( (- sthumbstickPosition) * scrollingSpeed);
A short explenation: the scrollrect can be manually moved via scrollRect.verticalNormalizedPosition = xyz.
When the thumbstick is up, it will return the value of 1. if it's down, it will return the value of -1. That means, if the thumbstick is down, you'll be subtracting a number from the verticalNormalizedPosition each frame, moving the scrollview up. And the opposite for the other direction. Cool part is, that youll be able to scroll faster the farther you go from the thumbstick center.
Fell free to ask me for a code implementation
04-08-2024 05:59 AM
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;
}
}
}
04-11-2024 02:04 PM
@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;