Added intro screen.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Intro : FadeCallback
|
||||
{
|
||||
public AudioSource music;
|
||||
|
||||
public MonoBehaviour faderScript; // Reference to the Fader script for handling the fade effect
|
||||
|
||||
private IEnumerator playAudioCoroutine;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() { }
|
||||
|
||||
public override void OnFadeStarted()
|
||||
{
|
||||
playAudioCoroutine = PlayAudioThenActivateGameObject();
|
||||
StartCoroutine(playAudioCoroutine);
|
||||
}
|
||||
|
||||
public override void OnFadeComplete() { }
|
||||
|
||||
public void forceStopAudioCoroutine()
|
||||
{
|
||||
if (playAudioCoroutine != null)
|
||||
{
|
||||
StopCoroutine(playAudioCoroutine);
|
||||
playAudioCoroutine = null;
|
||||
}
|
||||
|
||||
music.Stop();
|
||||
}
|
||||
|
||||
private IEnumerator PlayAudioThenActivateGameObject()
|
||||
{
|
||||
music.Play();
|
||||
yield return new WaitUntil(() => music.time >= music.clip.length);
|
||||
faderScript.Invoke("resetFader", 0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 594bb1fe3171425d5abf1bba51562952
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class IntroSkipper : MonoBehaviour
|
||||
{
|
||||
public Intro fadeIn;
|
||||
|
||||
public Fader fadeOut;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var keyboard = Keyboard.current;
|
||||
var mouse = Mouse.current;
|
||||
|
||||
if (keyboard != null && keyboard.anyKey.wasPressedThisFrame
|
||||
||
|
||||
mouse != null && mouse.leftButton.wasPressedThisFrame)
|
||||
{
|
||||
fadeIn.forceStopAudioCoroutine();
|
||||
fadeOut.resetFader();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee75bedbbbf072e1ca4d633925674475
|
||||
Reference in New Issue
Block a user