Adapting VR UI for Non-VR

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jibjab910
Posts: 18
Joined: Fri Mar 02, 2018 7:46 pm

Adapting VR UI for Non-VR

Post by jibjab910 »

I am developing a game in which the users can go through in either VR or non-VR. I like the setup of the VR UI in "VR UI Example" in the Dialogue System Extras, but I have been having some trouble making it work in a conventional scenario. Any advice on how to do this?
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adapting VR UI for Non-VR

Post by Tony Li »

That's a complex question. It depends on what you mean by making it work in a conventional scenario. As long as you can get the camera with the VR Eye Raycaster pointing at a UI button, then holding down the "Fire1" input button will make the timed slider click it.

As a quick proof of concept, you can use these steps in the VR UI Example scene:

1. Edit Player Settings (Edit > Project Settings > Player). In the XR Settings section, untick Virtual Reality Supported.

2. Drag the prefab Assets / Dialogue System / Examples / Prefabs / Player into the scene. Delete its Camera child GameObject.

3. Inspect the MainCamera GameObject. Add a Smooth Camera With Bumper component. Assign the Player's Head child GameObject to the Target field. Change Distance to 1 and Height to 2.

Play the scene. Aim the reticle at a button such as the NPC's "Talk to NPC" button, and hold down LMB.


Now if you want the UI to work differently in flat mode -- for example, using a regular single-click on a UI button -- that's a different story. Either way, it will almost certainly require at least a little scripting. Depending on how differently you want it to work, you could either add a little script that disables all the VR interaction components on each button, or you could create two UI buttons, one for VR and one for flat mode, and activate one of them depending on what mode you're in.


If you want to use a screen space UI for flat mode and world space UI for VR, that's more of a design issue.

Before I run on too long, I should just add that this applies to all UI interaction. It's not specific to the Dialogue System. You might want to set up a simple test scene with basic UI buttons that don't even involve the Dialogue System. This way you can test out all your interaction in a simple sandbox, and then later carry it over to the Dialogue System and elsewhere.
jibjab910
Posts: 18
Joined: Fri Mar 02, 2018 7:46 pm

Re: Adapting VR UI for Non-VR

Post by jibjab910 »

This works great! The only problem is that the player control of the camera is taken away (no control at all) when the "Talk to NPC" button is fully activated. Any ideas?
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adapting VR UI for Non-VR

Post by Tony Li »

There's probably a script on the player or camera, such as Set Enabled On Dialogue Event, that disables player control. You can remove this script.

Also make sure nothing is assigned to the Dialogue Manager's Camera Settings > Sequencer Camera or Alternate Camera Object, since these will deactivate the main camera during conversations.

And don't use any camera control sequencer commands such as Camera(), because these will obviously take control of the camera.
Eddington
Posts: 1
Joined: Mon Mar 12, 2018 7:05 am

Re: Adapting VR UI for Non-VR

Post by Eddington »

I don't understand. Why would this happen? Is this a built-in feature or a bug?
I think PhenGold is superb and better than anything else.
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adapting VR UI for Non-VR

Post by Tony Li »

Hi,

The Dialogue System doesn't take away any control by default. But it's possible for you to manually add a Set Enabled On Dialogue Event script to your scene and explicitly tell it to disable control. In my previous reply, I recommended to not do that in VR.

The same advice applies to the Camera() command. This command takes control of the camera. If you don't want to take away the player's control of the camera, don't use it.

If that doesn't help, please feel free to send an example scene or project to tony (at) pixelcrushers.com. I'll be happy to take a look.
Post Reply