Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
digital's avatar
digital
Explorer
11 years ago

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

3 Replies

Replies have been turned off for this discussion
  • I 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?