cancel
Showing results for 
Search instead for 
Did you mean: 

Francisco Rojas - Launch Pad "PHOBOS: Phobia VR Therapy" - Week 5

FrancisRedi
Protege
Today's development news is exciting because now PHOBOS is starting to feel like a real application.

At this time I have about 11 scenes created, with more on the way. However, they are all mostly disconnected with each other, nor are they really meant to be connected anyway. Rather a scene selection scene is required not only to get into those scenes, but to choose the relevant scenes to treat certain phobias featured in those scenes. Below is a working scene selection VR interface that does this. There are other scene place holders at the bottom that say 'Room' for now.

nzikvwhoa2h4.png

This functioning Scene Selector scene is based on Unity's UI System; it supports gaze input selection of scenes using gaze-pointer (with help provided by the example project mentioned here: https://developer.oculus.com/blog/unitys-ui-system-in-vr/ ). I'm currently using the same cursor as in the example, though it could change later. Each colored scene picture when hovered over by the cursor turns gray using sprite swapping and also comes forward a bit in response, then returns to colored and moved back on hover out.

3mty8uow6uwq.png

The clicking action is supported by the gamepad button or mouse, but I haven't tested on GearVR touchpad yet. Using the cursor, not only can you select the scene to load, but also scroll down using adjacent scroll bars to reveal more content. Highlighting a button on the left side reveals a description of the phobia in the orange area. However, at this time the scenes are not filtered by phobia features, a real challenging feature I have to figure out how to implement still if I choose to support it.

Unity has no built-in support for curving the UI. For that, there is a package in the Asset Store called Curved UI - VR Ready solution to bend / warp your canvas.
https://www.assetstore.unity3d.com/en/#!/content/53258

For gamepad controls, I use another Asset Store package called Rewired (https://www.assetstore.unity3d.com/en/#!/content/21676). So now I support 3 controllers with identical configuration: Xbox 360, Xbox One, and Steel Series Stratus XL for Win/Android - the one all participants got at Oculus Launchpad. Since the last one supports bluetooth connection, it will be suitable for GearVR application input. This is great because using the touchpad would be very unsuitable for PHOBOS and I don't need to change the control configuration just for GearVR. The way I currently configured the Steel Series Stratus XL is shown in the screen below. I configure via the rewired prefab to make sure that all scenes have the same control configurations, rather than have individual instances of it in each scene - a potential maintenance nightmare.

15gr1bz7fqpq.png

In PHOBOS, you can press 'back' button in each scene to go back to the scene selector scene.
Press 'back' again to go to PHOBOS logo scene.
Press 'back' again to exit app.
You can press 'start' to reset the camera tracking in all scenes.

Sample code:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LoadSceneSelector : MonoBehaviour {

    private Rewired.Player input;
    private int doOnce = 0;

    // Use this for initialization
    void Start () {
        input = Rewired.ReInput.players.GetPlayer(0);
        StartCoroutine(Wait());
    }
// Update is called once per frame
void Update () {
        if (input.GetButtonDown("A") && doOnce < 1){
            doOnce++;
            SceneManager.LoadSceneAsync("HomeScene", LoadSceneMode.Single);
        }
        if (input.GetButtonDown("Recenter"))
        { // center tracking on current pose
            UnityEngine.VR.InputTracking.Recenter();
        }
        if (input.GetButtonDown("Back"))
        {
            #if UNITY_EDITOR
                //Debug.Break(); // pause the game
                UnityEditor.EditorApplication.ExecuteMenuItem("Edit/Play");
            #elif UNITY_WEBPLAYER
                string webplayerQuitURL = "http://francisco.altervista.com";
                Application.OpenURL(webplayerQuitURL);
            #elif UNITY_STANDALONE_WIN
                Application.Quit();
            #endif
        }
    }

    IEnumerator Wait()
    {
        yield return new WaitForSeconds(5);
    }
}


0 REPLIES 0