What I want is a world space canvas that I can scroll using hand movements. I can get the worldPosition of the controllers and find the actual movement but I cannot figure out how to enable the text to scroll.
What I am trying at the moment is to use a scrollrect+ a hidden scrollbar and change the value of the scrollbar but this doesn't work.
I have also tried changing the world position of the textobject and while I managed to make the text to move accordingly I cannot figure out how to find the text size, but I think this is like reinventing the scrollrect.
For anyone checking this now, I ld propose to use the OVR Input module with its scroller components provided in the oculus framework. I 'm leaving my old answer below.
After some more search I stumbled upon an answer in the unity forums, I m posting it here for future reference.
Here you just scroll with the assigned axis as setup in the project settings, if you want to scroll with hand movements just calculate the difference between controller position, for oculus touch I could get mine through changing a bit their code from here https://developer.oculus.com/blog/adding-gear-vr-controller-support-to-the-unity-vr-samples/
public class MoveScrollRect : ScrollRect, IMoveHandler, IPointerClickHandler
{
private const float speedMultiplier = 0.01f;
public float xSpeed = 0;
public float ySpeed = 0;
private float hPos, vPos;
void IMoveHandler.OnMove(AxisEventData e)
{
xSpeed += e.moveVector.x * (Mathf.Abs(xSpeed) + 0.1f);
ySpeed += e.moveVector.y * (Mathf.Abs(ySpeed) + 0.1f);
}
void Update()
{
ySpeed = Input.GetAxis("VerticalScroller");
hPos = horizontalNormalizedPosition + xSpeed * speedMultiplier;
vPos = verticalNormalizedPosition + ySpeed * speedMultiplier;
xSpeed = Mathf.Lerp(xSpeed, 0, 0.1f);
ySpeed = Mathf.Lerp(ySpeed, 0, 0.1f);
if (movementType == MovementType.Clamped)
{
hPos = Mathf.Clamp01(hPos);
vPos = Mathf.Clamp01(vPos);
}
normalizedPosition = new Vector2(hPos, vPos);
}
public void OnPointerClick(PointerEventData e)
{
EventSystem.current.SetSelectedGameObject(gameObject);
}
public override void OnBeginDrag(PointerEventData eventData)
{
EventSystem.current.SetSelectedGameObject(gameObject);
base.OnBeginDrag(eventData);
}
}