Skip to main content
Participant
July 15, 2016
Solved

The Mysterious Volume UI

  • July 15, 2016
  • 32 replies
  • 12989 views
I'm trying to get my Unity app ready for submission. I'm using Unity version 5.3.5p5 and Oculus Utilities for Unity 5 V1.5.0. I've gotten the needed back button functionality working, but for the life of me I can't figure out the required volume UI. In the utilities, there's a VolumeController prefab under Moonlight that's missing a script, though I thought I've read other things are supposed to be supplying the Volume UI (OVRManager?). Nothing has worked so far. I even tried the Oculus Sample Framework for Unity 5 Project Oculus provides, but that doesn't have the volume UI working in it either. So I don't even have a working version to work back from.

Does anyone have any idea how to get the Volume UI working in 1.5.0? All the help online I've been able to find seems to refer to earlier version of the Oculus utilities and scripts that no longer exist.
    This topic has been closed for replies.
    Best answer by ProfessorTroy
    Alright!

    So the newest Unity package is missing the OVRVolumeControl.

    Here is a version that "works" with the current package. It won't show the volume bar if you're already at max/min values, because the event that the button was hit appears to be missing so you can't key off it here.

    I added the LastVolumeInput, TempVolumeInput and TimeToCheck values so it tracks when the volume has changed. There was some minor changes made to the Update function as well.

    Add this behavior to the prefab with the missing script.
    Add that prefab to your camera.
    Position it where you want it to appear in the users vision.
    Blamo - it'll work.


    Cheers!

    using UnityEngine;
    using System.Collections;

    public class OVRVolumeControl : MonoBehaviour
    {
        private const float         showPopupTime = 3;
        private const float            popupOffsetY = 64.0f / 500.0f;
        private const float            popupDepth = 1.8f;
        private const int             maxVolume = 15;
        private const int             numVolumeImages = maxVolume + 1;
        
        private Transform            myTransform = null;

        private float LastVolumeInput;
        private float TempVolumeInput;
        private float TimeToCheck = 0.0f;
        
        void Start()
        {
            DontDestroyOnLoad( gameObject );
            myTransform = transform;
            GetComponent<Renderer>().enabled = false;
            LastVolumeInput = OVRManager.volumeLevel;
        }

        void Update()
        {
            UpdatePosition(Camera.main.transform);
        }

        /// <summary>
        /// Updates the position of the volume popup. 
        /// </summary>
        public void UpdatePosition(Transform cameraTransform)
        {
            // OVRManager.volumeLevel returns a negative value in GearVR/Unity until the button is hit at least once.
            
            float check = OVRManager.volumeLevel;
            if ((check < 0f) || (check == LastVolumeInput))  // we haven't gotten a volume button check yet.
            {
                TimeToCheck = 0f;
            }
            else
            {
                LastVolumeInput = -10; // there was a change, let this play out.
                if (TempVolumeInput != check)
                    TimeToCheck = 0.0f;

                TempVolumeInput = check;
                // Volume has changed...
                TimeToCheck += Time.deltaTime;

                if ((TimeToCheck < showPopupTime)) // for the next three seconds ....
                {
                    GetComponent<Renderer>().enabled = true;
                    GetComponent<Renderer>().material.mainTextureOffset = new Vector2(0.0f, (float)(maxVolume - (OVRManager.volumeLevel*maxVolume) ) / (float)numVolumeImages);
                    if (myTransform != null && cameraTransform != null)
                    {
                        // place in front of camera
                        myTransform.rotation = cameraTransform.rotation;
                        myTransform.position = cameraTransform.position + (myTransform.forward * popupDepth) + (myTransform.up * popupOffsetY);
                    }
                }
                else
                {
                    // 3 seconds have passed...
                    TimeToCheck = 0.0f;
                    LastVolumeInput = check;
                    GetComponent<Renderer>().enabled = false;
                }
            }
        }
    }

    32 replies

    fflemingAuthor
    Participant
    July 15, 2016
    I should add I'm using Unity's camera and not the OVRCameraRig, but again I didn't see the volume UI working in a  sample project using the OVRCameraRig.
    July 15, 2016
    I have the same problem. We're on Unity 5.3.5f1 and using Utilities 1.5.0. For the life of me I can't find anything in the documentation.
    Inspiring
    July 15, 2016
    I'm dealing with similar feedback at the moment. I'll return to add information if I solve it before you.
    I suspect we're suppose to do something with the OVRManager.volume and have it actually affect sounds in game.

    However, I'm not entirely sure either as it's kind of ambiguous what they're asking for.

    Do you have a volume slider bar functional in your project?
    fflemingAuthor
    Participant
    July 15, 2016

    Do you have a volume slider bar functional in your project?


    No. The volume buttons work. Just nothing graphically happens right now. I might play with an older version of the Oculus Utilities as more people seemed to have solved how to use the Volume UI with that.
    July 15, 2016
    I'm not sure it's OVRManager.volume. The volume is accurately changing. I just cant get the volume bar to show up. I read somewhere that you have to attach OVRVolumeControl to a game object in the scene, but that doesn't seem to work either.

    I should mention that I'm developing for Gear VR 
    Inspiring
    July 15, 2016
    When you say "The Volume Buttons" work, do you mean ones you added yourself, or the ones you access via the settings menu by holding the back button??

    I should also mention I'm developing for Gear VR.
    Where do you see the OVRVolumeControl?  I don't have this in any of the SDKs I've downloaded so far.
    fflemingAuthor
    Participant
    July 15, 2016


    When you say "The Volume Buttons" work, do you mean ones you added yourself, or the ones you access via the settings menu by holding the back button??


    I mean the physical buttons on the Gear VR make the volume go up and down. There is just not the UI appearing showing the volume going up and down.
    Inspiring
    July 15, 2016
    Holy man I feel retarded right now. There's volume buttons on the side of the headset!!
    Yeah - ok now I get what's going on here. 
    July 15, 2016
    Same here. Physical volume buttons work, UI doesn't.
    Inspiring
    July 15, 2016
    I have a fix pending - will post in 20-30 minutes once I verify it working.