Getting around the black screen on WaveSDK-2.1.0 on Unity 2018.2.x

john__primitive
Settler

Getting around the black screen on WaveSDK-2.1.0 on Unity 2018.2.x

In case it hasn't been addressed here before, the black screen that appears on first load that is only dismissable by pausing the application (by removing the headset and putting it back on), can be automatically cleared by forcing the application to pause and unpause on first load.

 

Doing a forced pause and unpause requries a modification to the WaveSDK code in WaveVR_Render in OnApplicationPause():

 

    void OnApplicationPause(bool pauseStatus)
    {
        Pause(pauseStatus);
    }

    public void Pause(bool pauseStatus)
    {
        Log.d(LOG_TAG, "Pause(" + pauseStatus + ")");

        if (pauseStatus)
        {
            WaveVR_Utils.IssueEngineEvent(WaveVR_Utils.EngineEventID.UNITY_APPLICATION_PAUSE);
            if (synchronizer != null)
                synchronizer.sync();
            lefteye.getCamera().targetTexture = null;
            righteye.getCamera().targetTexture = null;
            textureManager.ReleaseTexturePools();
        }
        else
        {
            WaveVR_Utils.IssueEngineEvent(WaveVR_Utils.EngineEventID.UNITY_APPLICATION_RESUME);
        }

        setLoadingCanvas(true);
        enableRenderLoop(!pauseStatus);
    }

Pause can then be called externally, ideally from a coroutine or a late update with a small delay to allow for the WaveSDK assets to load. The pause and unpause in the renderloop is inperceptible to the user.

 

This is a hack and will hopefully be addressed in a future release.

Florian13
Settler

Re: Getting around the black screen on WaveSDK-2.1.0 on Unity 2018.2.x

My hero. Thanks man. Like... a lot Smiley Very Happy

Florian13
Settler

Re: Getting around the black screen on WaveSDK-2.1.0 on Unity 2018.2.x

Actually, for some reasons, it worked (or I thought it worked) the first time, and then not anymore. I tried everything I possibly could.

 

Could you please explain how the Pause method is intended to be used? I tried to call Pause(false) 3 seconds after my player OnEnable. No luck.

Did you change the Scripts Execution Order like recommended in the "documentation"?

Do you need to keep a WaveVR_Init (from [WaveVR] prefab) in the scene?

 

This has been driving me nut for a few days now... Your help would be much appreciated!

mender
Settler

Re: Getting around the black screen on WaveSDK-2.1.0 on Unity 2018.2.x

I think the idea is that you first pause and then unpause. Doing it in LateUpdate wasn't late enough for me though. I ended up getting the first frame, but there was no positional tracking or anything else. It seemed like the first frame was just constantly rendered (with a bit of flickering). If I delay it by 1 second in a coroutine, then it works. I just attached this to the WaveVR camera object:

 

using System.Collections;
using UnityEngine;

public class PauseUnpauseWaveVR : MonoBehaviour {
    private void OnEnable()
    {
        StartCoroutine(ForceWVRPause());
    }

    private IEnumerator ForceWVRPause()
    {
        yield return new WaitForSecondsRealtime(1f);

        var wvrRender = GetComponent<WaveVR_Render>();
        wvrRender.Pause(true);
        wvrRender.Pause(false);
        Destroy(this);
    }
}
Florian13
Settler

Re: Getting around the black screen on WaveSDK-2.1.0 on Unity 2018.2.x

Why didn't I try that last night? Smiley LOL 

It works!

 

Thanks @mender!