Go back

KNVB VR Experience

A VR experience as promotion for the Dutch national women's football team




About this project

Engine Unity/C#
Platform(s) GearVR
This GearVR app was created together with Imagine5 and commissioned by the KNVB for a promotional tour for the Dutch national women's football team.

For this project I did all the work in Unity which consists of the programming and the composition of the scenes.

In the app the user is shown various 360 degree videos recorded just before a football match. It also features a 'find the player' minigame in which the user has to find different players.

This project is one of many VR projects I've done with Imagine5. Others include Sligro VR, PSV VR, Topsportcentrum Almere VR and Presikhaaf Schoolmeubelen VR.

Downloads and links

SceneController.cs

The main controller of the scene switching. The app uses a base scene with the VR camera and loads all the content scenes on top of the base scene.

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

public class SceneController : SingletonMonoBehaviour<SceneController>
{
	#region Constants

	private const string StartScene = "Main Video";

	#endregion

	#region Events

	public delegate void SceneStartHandler();
	public event SceneStartHandler SceneStart;
	public delegate void SceneSwitchHandler(string sceneName);
	public event SceneSwitchHandler SceneSwitch;

	#endregion

	#region Variables

	private List<object> _loadingObjects = new List<object>();
	private bool _loading = false;

	#endregion

	#region Properties

	public string CurrentScene { get; private set; }

	#endregion

	#region Lifecycle

	private void Start()
	{
		SwitchScene(StartScene, FadeState.OnlyFadeOut);
	}

	private void Update()
	{
		if(Input.GetKeyDown(KeyCode.Escape))
		{
			SwitchScene(StartScene);
		}
	}

	#endregion

	#region Public Methods

	public void SwitchScene(string path, FadeState fadeState = FadeState.Normal)
	{
		if(!_loading)
		{
			StartCoroutine(SwitchSceneCo(path, fadeState));
		}
	}

	public void AddLoadingObject(object obj)
	{
		_loadingObjects.Add(obj);
	}

	public void RemoveLoadingObject(object obj)
	{
		_loadingObjects.Remove(obj);
	}

	#endregion

	#region Private Methods

	private IEnumerator SwitchSceneCo(string sceneName, FadeState fadeState = FadeState.Normal)
	{
		_loading = true;

		bool fadeFinished = true;
		if(fadeState == FadeState.Normal)
		{
			fadeFinished = false;
			UIController.Instance.FadeIn(() => fadeFinished = true);
		}
		else if (fadeState == FadeState.OnlyFadeOut)
		{
			UIController.Instance.InstantFade();
		}

		while(fadeFinished == false) yield return null;

		//Unload the previous scene
		if(CurrentScene != null)
		{
			AsyncOperation asyncUnload = SceneManager.UnloadSceneAsync(CurrentScene);
			while(!asyncUnload.isDone) yield return null;
		}

		CurrentScene = sceneName;

		if(SceneSwitch != null)
		{
			SceneSwitch(sceneName);
		}

		//Start loading the scene
		AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
		while(!asyncLoad.isDone) yield return null;

		yield return null;

		while(_loadingObjects.Count > 0) yield return null;

		if(SceneStart != null)
		{
			SceneStart();
		}
}

		if(fadeState == FadeState.Normal || fadeState == FadeState.OnlyFadeOut)
		{
			UIController.Instance.FadeOut(null);
		}

		yield return new WaitForSeconds(2f);

		_loading = false;
	}

	#endregion

	public enum FadeState
	{
		Normal,
		OnlyFadeOut,
		NoFade
	}
}