Skip to content

Instantly share code, notes, and snippets.

@atakotestudios
Created May 20, 2017 19:35
Show Gist options
  • Save atakotestudios/b736161f1ea5463fbe6ffaefbdb74b97 to your computer and use it in GitHub Desktop.
Save atakotestudios/b736161f1ea5463fbe6ffaefbdb74b97 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
[RequireComponent(typeof(SteamVR_LoadLevel))]
public class GameManager : MonoBehaviour {
public int score;
public int projectilesThrown;
public bool countNumberOfProjsThrown = true;
public int projectilesPerLevel = 5;
public bool loadLevelScreenFade = false;
private static int levelNum;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (countNumberOfProjsThrown)
{
if(projectilesThrown >= projectilesPerLevel)
{
projectilesPerLevel = 0; //prevents this code from firing multiple times
levelNum++;
if (loadLevelScreenFade)
{
//will only work if naming convenction is Scene0, Scene1, etc (can be customized to own convention)
SteamVR_LoadLevel.Begin("Scene" + levelNum);
}
else
{
//instant scene load with no fade
SceneManager.LoadScene(levelNum);
}
}
}
}
public void CountProjectiles()
{
projectilesThrown++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment