1
\$\begingroup\$

How can I make a progress bar appear in Unity that doesn't make use of the OnGUI functionality in C#?

I'm doing something with an Oculus and the OnGUI stuff doesn't work too well in a stereoscopic setting. I'm open to hear suggestions or try code samples as I can't seem to think of a way to display this in Unity and every google search brings up OnGUI examples.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ If you can't use GUI.X functions your best bet would be to parent some planes or cubes to the front of the camera as GUI objects. A progress bar should be no more than two planes (one for the background progress bar container texture and one for the fill texture). You can then either resize them in OnGUI (best option) or LateUpdate. \$\endgroup\$ Commented Oct 24, 2013 at 23:50

1 Answer 1

1
\$\begingroup\$

I think all the normal Unity answers (nGUI, etc.) aren't going to help you. I'm looking into VR stuff now, and standard 2D techniques just don't work well. Ideally you want to put your UI into the world, but adjust its position based on the camera.

Simplest answer I can suggest is to create a simple cuboid Mesh object, parented underneath your OVRCameraController (so it's essentially locked to your head) and positioned such that it's always visible in front of your viewpoint. Then animate its transform over time (e.g. scale it from 0.0 to 1.0 along one axis to make it appear as if it were growing.

Actually, given the lack of frame of reference, a standard progress bar might not be so good. Maybe try a cube which scales down to 0,0,0 (i.e. shrinks and disappears when the progress bar is done). Or maybe have two cuboids, one transparent and sized at 100%, the other sized at 0% and scaling up. When the two cuboids are the same size the progress bar is done.

\$\endgroup\$
2
  • \$\begingroup\$ Why would NGUI not help the OP? \$\endgroup\$
    – Bart
    Commented Nov 2, 2013 at 22:46
  • \$\begingroup\$ Well, because nGUI, like all the other common UI building plugins is primarily made to support 2D techniques, and renders through a single viewport. In a VR setting, you need to show the UI twice, once for each eye-viewport. You could hang a 2D nGUI UI in front of the VR camera I suppose, if you could sort out the draw order so that the UI always shows on top of 3D, but you'd probably still run into issues with the user struggling to focus on a flat thing, feeling uncomfortably close to their face. Although you could maybe project the 2D plane of the UI into the scene from the viewpoint. \$\endgroup\$
    – MrCranky
    Commented Nov 6, 2013 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .