Forum Discussion
digital
11 years agoExplorer
Unity 4.6 UI?
Hi!
Has anybody got the new Unity 4.6 UI system integrated with the OVRCameraController?
I have started to build a custom `VRInputModule` and thought it would be a case of RayCasting where the player is looking and seeing what button it is gazing at. It looks like the UI Canvas and sub-elements are completely outside of the normal 3d space and handled very differently.
Any thoughts?
Regards:
John
Has anybody got the new Unity 4.6 UI system integrated with the OVRCameraController?
I have started to build a custom `VRInputModule` and thought it would be a case of RayCasting where the player is looking and seeing what button it is gazing at. It looks like the UI Canvas and sub-elements are completely outside of the normal 3d space and handled very differently.
Any thoughts?
Regards:
John
3 Replies
Replies have been turned off for this discussion
- digitalExplorerI made a start but it feels like the ugliest code I have ever hacked together... I have never had to extend anything inside Unity and a lot of the essential methods are protected.
Basically is extends the standard input module but instead of using the mouse position, its using a magic Vector2 with the correct center position.
Hover/rollover works as expected but there are still issues.- Unity needs focus for it to work otherwise no selection happens. I guess it disables it if there is no mouse present.
- Need to disable directional movement. You can still use a joystick to move the selection.
- For some reason I cant get activation to work on a xbox controller press. It seems to only work on mouse click.
using System;
using UnityEngine.UI;
namespace UnityEngine.EventSystems
{
[AddComponentMenu ("Event/VR Input Module")]
public class VRInputModule : StandaloneInputModule
{
PointerEventData lastpointerData;
override protected PointerEventData GetMousePointerEventData ()
{
Vector2 mousePosition = new Vector2(600f, 728.0f);
if(lastpointerData == null){
lastpointerData = new PointerEventData(base.eventSystem);
}
PointerEventData pointerEventData = lastpointerData;
pointerEventData.Reset ();
pointerEventData.position = mousePosition;
Vector2 vector = mousePosition;
pointerEventData.delta = vector - pointerEventData.position;
pointerEventData.position = vector;
base.eventSystem.RaycastAll (pointerEventData, this.m_RaycastResultCache);
RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast (this.m_RaycastResultCache);
pointerEventData.pointerCurrentRaycast = pointerCurrentRaycast;
this.m_RaycastResultCache.Clear ();
return pointerEventData;
}
}
}
Can anybody help take this further? - AnonymousI'm just getting started with 4.6, but have you seen this?
http://ralphbarbagallo.com/2014/08/20/oculus-rift-world-space-cursors-for-world-space-canvases-in-unity-4-6/
And this (search for Oculus)?
http://forum.unity3d.com/threads/frequently-asked-ui-questions.264479/ - digitalExplorerThanks for the links! Much appreciated.
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
- 10 months ago
- 1 month ago
- 8 months ago
- 1 year ago