Search Unity

World space canvas with scrollbar

Discussion in 'AR/VR (XR) Discussion' started by Timescar, Oct 7, 2015.

  1. Timescar

    Timescar

    Joined:
    Oct 7, 2015
    Posts:
    11
    Hi everyone, this is my first time posting here.
    I have made my crosshair with oculus by following eVRydayVR's tutorial, I used raycasting to interact with my 3d objects.
    Now I wanted to implement a world space canvas that contains text and has a scrollbar, which I did by following Brackey's tutorial


    But my problem is that I can't interact with it when I look at it with my crosshair :(.
    Can one of you knowledgeable people guide me on how I can make my scrolling work, thanks in advance :).

    I am using unity 5 at the moment, if you need any more details please tell me and I'll provide them!
     
  2. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    I'm not sure of how would it be to interact the scroll region moving my neck :) but maybe you could have buttons (that you already know how to interact with) to make the movement?
     
  3. Timescar

    Timescar

    Joined:
    Oct 7, 2015
    Posts:
    11
    That maybe a good alternative for now, can you tell me how I can control the scrollbar movement through a script, preferably in c#?
    Thanks in advance :)
     
  4. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    You have to modify verticalNormalizedPosition or horizontalNormalizedPosition in a ScrollRect reference. Normalized means from 0 to 1 (float), so it doesn't depend on the actual size, but a percentage.
     
    Timescar likes this.
  5. Timescar

    Timescar

    Joined:
    Oct 7, 2015
    Posts:
    11
    Works just fine thanks, but now I have another problem I add text to my list but the scrolling stops depending on the size value of y of the text rectangle.
    How can I make the scrolling/text rectangle to be dependent on the text amount?

    Nevermind http://docs.unity3d.com/460/Documentation/Manual/UIAutoLayout.html :)
     
  6. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    Never tried with a single text element that changes, but adding the layout element script to it I guess it would help. I don't know if it needs a layout script in the parent (vertical layout or similar).
    At least it should guide you in the right direction with keywords :)
     
  7. Timescar

    Timescar

    Joined:
    Oct 7, 2015
    Posts:
    11
    The layout element and content size fitter was just what I needed, I just attached it to the text field and that was it, changed the min height in my case using the layout element script.
    Thanks for your suggestion no more UI headaches for now :D!
     
    DrBlort likes this.
  8. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    Glad that it helped!