WaveVR FadeOut Effect


This tutorial shows you how to use the fade-out effect in Unity. See the example below.


First, create a new Java file with following content:

import com.htc.vr.sdk.VRActivity;
import com.htc.vr.unity.WVRUnityVRActivity;

class Sample_FadeOut{

    private static Sample_FadeOut mInstance = null;
    private WVRUnityVRActivity mActivity;
    private Context mContext;
    private Handler mHandler;
    FadeOutStartActivity mFadeOutRunnable;

    public Sample_FadeOut(WVRUnityVRActivity activity) {

        mActivity = activity;
        mContext = (Context)activity;
        //Cause this effect need executed in the main thread
        mHandler = new Handler(mContext.getMainLooper());
    public static Sample_FadeOut getInstance(WVRUnityVRActivity activity){
        if (mInstance == null) {
            mInstance = new Sample_FadeOut(activity);
        return mInstance;

    public void FadeOut(){
        this.mFadeOutRunnable = new FadeOutStartActivity();
        this.mHandler.postDelayed(this.mFadeOutRunnable, 1)

    private class FadeOutStartActivity implements Runnable{
        public FadeOutStartActivity() {}

        public void run(){
            Runnable runnable = new Runnable(){
                public void run(){
                    Intent permIntent = new Intent("android.intent.action.MAIN");
                    permIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |  Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                    permIntent.putExtra("QuickMenuEvent", 1);

In VIVE Wave™ SDK the above Java file is already included in wvr_client.aar and wvr_unity_plugin_2017.aar under plugin/Assets/WaveVR/Platform/Android. So that you can use it directly.

Then you can use the fade-out effect by C# script as following:

private const string FADEOUT_CLASSNAME = "com.htc.vr.sample.Sample_FadeOut";

void Start () {
    using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity")){
            AndroidJavaClass ajc_setting = new AndroidJavaClass(FADEOUT_CLASSNAME);

            //Cause this effect need executed in the main thread, sending currentActivity to fadeout_class
            fadeout_class = ajc_setting.CallStatic<AndroidJavaObject>("getInstance", jo);