ExtendRealityLtd / VRTK

An example of how to use the Tilia packages to create great content with VRTK v4.
https://www.vrtk.io/
MIT License
3.69k stars 993 forks source link

UI Pointer - Don't automatically initialize world canvases #421

Closed aronschatz closed 8 years ago

aronschatz commented 8 years ago

In my games, I support VR and 2D. I have some helper scripts for things like menus and such that detect if VR is present and then enable them for VR.

The UI pointer script needs an option to not try to make every world canvas interactable. Maybe a public boolean saying to not run on startup, or something. I'm basically doing that now and upon detecting VR support, another script calls the setup per canvas that needs it.

The second thing deals with the pointer for interacting with the UI Pointer. It would be nice to set the layer of the beam being projected, publicly. This way, when I show a UI world canvas, I can force that to show over top anything else, and the beam will be visible.

A question, is UI Pointer required to be on a controller? I'm not on my Unity box right now, but would it be fine on the camera rig... or?

thestonefox commented 8 years ago

You can specify the UI Pointer to ignore certain canvases using the "Ignore Canvas With Tag Or Class" parameter: https://steamvr-unity-toolkit.readme.io/docs/vrtk_uipointer#section-inspector-parameters

I'm not sure about your second point, are you saying you want the actual pointer beam to auto display when you point at a canvas?

You can point the UI pointer on any object including the headset, check the example scene to see this in action: 034_Controls_InteractingWithUnityUI

aronschatz commented 8 years ago

I'm not a fan of the ignore with tag or class since it is too limiting and makes things messy. I'd like something on "Only run on objects with class or layer" (an include instead of exclude). Regardless, if I don't want it running on anything at runtime, there's no way to do that... Unless it takes a wildcard character? Does it? I'll have to dig in the code again.

The second point deals with layers and camera culling. For example, in a game, I have a pause menu. That menu makes a world space canvas. The problem is that the canvas may be behind other objects in the scene. There's a few ways to take care of this. Have a second camera that turns on and only shows the UI layer... Or, show the second camera on top of the primary in depth only mode with the UI layer on top. In either case, the pointer beam will be behind the world space canvas to the user since it's layer isn't settable. It would be very helpful to be able to set the pointer beam layer.

wildstyle007 commented 8 years ago

I'm my project I've extended the VRTK_SimplePointer, as I only wanted it optionally to be visible on a certain objects.. so I modified as follows to show only for certain tags. Note 'TagLimitPointerVisibility' is a public field that can be set from the editor. I'm also using TagFrenzy ( https://www.assetstore.unity3d.com/en/#!/content/13170 ).

Code override in Update:

if (!string.IsNullOrEmpty(TagLimitPointerVisibility))
{
    if (pointerContactTarget != null)
    {
        List<string> tags = pointerContactTarget.gameObject.tags();
        if (tags.Contains(TagLimitPointerVisibility))
        {
            // Turn something on logic
            return;
        }
    }
    // Turn something off logic
}