Forum Discussion
ffleming
9 years agoExplorer
The Mysterious Volume UI
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.
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.
- 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;
}
}
}
}
- Got it working, but man does it feel hacky. I started with 1.5.0 integration tools, but I also downloaded the 1.3.0 legacy integrations tools for 4.x Unity. I attached OVRManger.cs (1.5.0) to my camera and added the OVRVolumeController prefab under Moonlight as a child to the camera (probably could go anywhere, though). I then used the OVRVolumeController script from 1.3.0 and put that in the missing script for the prefab.
Next I searched the 1.3.0 version of OVRManager.cs for all reference to volume controller and added that to the 1.5.0 version. One line needed to be modified since I was not using the OVRCameraRig and OVRManager is attached to the camera.if (volumeController != null)
became
{
if (volumeControllerTransform == null)
{
if (gameObject.GetComponent<OVRCameraRig>() != null)
{
volumeControllerTransform = gameObject.GetComponent<OVRCameraRig>().centerEyeAnchor;
}
}
volumeController.UpdatePosition(volumeControllerTransform);
}if (volumeController != null)
{
if (volumeControllerTransform == null)
{
volumeControllerTransform = gameObject.transform;
}
volumeController.UpdatePosition(volumeControllerTransform);
}And now it's working.
- > So the newest Unity package is missing the OVRVolumeControl.
OVRVolumeControl was intentionally removed. Please use Unity 5.3.5p6 or higher, which uses the Oculus Mobile SDK's built-in volume control.
32 Replies
Replies have been turned off for this discussion
- ProfessorTroyAdventurerAlright!
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;
}
}
}
}
- fflemingExplorerGot it working, but man does it feel hacky. I started with 1.5.0 integration tools, but I also downloaded the 1.3.0 legacy integrations tools for 4.x Unity. I attached OVRManger.cs (1.5.0) to my camera and added the OVRVolumeController prefab under Moonlight as a child to the camera (probably could go anywhere, though). I then used the OVRVolumeController script from 1.3.0 and put that in the missing script for the prefab.
Next I searched the 1.3.0 version of OVRManager.cs for all reference to volume controller and added that to the 1.5.0 version. One line needed to be modified since I was not using the OVRCameraRig and OVRManager is attached to the camera.if (volumeController != null)
became
{
if (volumeControllerTransform == null)
{
if (gameObject.GetComponent<OVRCameraRig>() != null)
{
volumeControllerTransform = gameObject.GetComponent<OVRCameraRig>().centerEyeAnchor;
}
}
volumeController.UpdatePosition(volumeControllerTransform);
}if (volumeController != null)
{
if (volumeControllerTransform == null)
{
volumeControllerTransform = gameObject.transform;
}
volumeController.UpdatePosition(volumeControllerTransform);
}And now it's working.
- AnonymousNot applicableNice. Thanks.
This is way out of my realm of expertise, but I'll have our programmer take a look and see if he can get it working.
I'll post results once I have something to report. - vrdavebOculus Staff> So the newest Unity package is missing the OVRVolumeControl.
OVRVolumeControl was intentionally removed. Please use Unity 5.3.5p6 or higher, which uses the Oculus Mobile SDK's built-in volume control. - vrdavebOculus StaffYes. If you need to use p5, please stay on Utilities 1.4 or earlier.
- ProfessorTroyAdventurer>.< doh.
- RemiLExplorer
vrdaveb said:
> So the newest Unity package is missing the OVRVolumeControl.
OVRVolumeControl was intentionally removed. Please use Unity 5.3.5p6 or higher, which uses the Oculus Mobile SDK's built-in volume control.
I'm using the beta 21 and I don't manage to get the UI volume working since 1.5.0 (except using old script or modifying OVR's script).What are the simple steps to make it work in the right way ?Thank
Edit: Just updated to the RC (5.4.0f1), it works. - plysaght47ExplorerGlad I found this forum, volume UI issues for me as well.
My project was built on Unity 5.3.5f1 and worked fine except for the volume UI. I tried to fix it by downloading the new Utilities and going to 5.3.5p6. The volume UI worked in this case, however, I encountered some issues upon testing. Mainly, my screen started jittering when I would look around, all smoothness ceased, and the game is virtually unplayable. The same thing happened when I tried 5.3.5p8. No idea why.
I should mention I am developing for GearVR and I am not using the OVRCameraRig.
I've also tried adding in the old OVRVolumeprefab which will show up if I enable it on start, but does not sync/react to volume input (in 5.3.5f1 that is).
This is one of two items of my requested changes from the review team; I'm a bit frustrated.
Thanks. - AnonymousNot applicable@plysaght47 We got the same issue upgrading to 5.3.5p6 and 8. I'm not sure what's causing it, but at least you're not alone. I think we're staying with f1 until something improves.
I was told by a Unity rep that 5.3.6f1 was coming soon. I really hope that stuff get's fixed in that version.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 5 months ago
- 16 days ago
- 7 months ago
- 3 months ago