Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- // <summary>
- // Splash screen.cs
- // Bj Thomas
- // 8/20/2018
- // <summary>
- public class ControllerWarning : ControllerManager {
- public Texture2D _controllerWarningBackground; //Create slot in inspector to assign the controller warning background
- public Texture2D _controllerWarningText; //Create slot in inspector to assign the controller warning text message
- public Texture2D _controllerDetectedText; //Create slot in inspector to assign the controller detected text message
- public float _controllerWarningFadeValue; //Defines the fade value of the warning text
- private float _controllerWarningFadeSpeed = 0.25f; //Defines the fade speed
- private bool _controllerConditionsMet; //Defines if the controller conditions are met for the game to continue
- // Use this for initialization
- void Start () {
- _controllerWarningFadeValue = 1; //Fade value equals one on startup
- _controllerConditionsMet = false; //Controller condintions met is false on startup
- }
- // Update is called once per frame
- void Update () {
- if (_controllerDetected == true) //if controller detected equals true
- StartCoroutine("WaitToLoadMainMenu"); //Start WaitToLoadMainMenu function
- if (_controllerConditionsMet == false) //if controller condition met equals false
- return; //then do nothing and return
- if(_controllerConditionsMet == true){ //if controller conditions met equals true
- _controllerWarningFadeValue -= //decrease fade value
- _controllerWarningFadeSpeed //by fade speed
- * Time.deltaTime; //times delta time
- if (_controllerWarningFadeValue < 0) //if fade equals zero
- _controllerWarningFadeValue = 0; //then set fade value to equal zero exactly
- if (_controllerWarningFadeValue == 0)
- {
- _startUpFinished = true; //Set startup finished to true
- SceneManager.LoadScene("MainMenu"); //load main menu scene
- }
- }
- }
- private IEnumerator WaitToLoadMainMenu(){
- yield return new WaitForSeconds(2); //wait for this (x) many seconds
- _controllerConditionsMet = true; //Set controller condition met to true
- }
- private void OnGUI(){
- GUI.DrawTexture(new Rect(0, 0, //Draw Texture starting at 0,0
- Screen.width, Screen.height), //by the screen width and height
- _controllerWarningBackground); //draw the warning background
- GUI.color = new Color(1,1,1, //GUI color is equal to 1 1 1 (rgb default)
- _controllerWarningFadeValue); //plus the fade value
- GUI.DrawTexture(new Rect(0, 0, //Draw Texture starting at 0,0
- Screen.width, Screen.height), //by the screen width and height
- _controllerWarningText); //draw the controller warning text
- if(_controllerDetected == true) //if controller detected equals true
- GUI.DrawTexture(new Rect(0, 0, //Draw Texture starting at 0,0
- Screen.width, Screen.height), //by the screen width and height
- _controllerDetectedText); //draw the controller detected text
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement