Added intro screen.

This commit is contained in:
2026-06-24 14:01:18 -04:00
parent 9f5ec96e18
commit 855679391a
20 changed files with 839 additions and 30 deletions
-17
View File
@@ -1,17 +0,0 @@
using UnityEngine;
public class EndSplash : MonoBehaviour
{
// 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() { }
void OnFadeStarted() { }
void OnFadeComplete()
{
UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 537357e1739e92da0baf85b7aef8a612
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+46
View File
@@ -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);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 594bb1fe3171425d5abf1bba51562952
+30
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ae5479cb3e81a6773b311e88ba24952d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,11 +1,10 @@
using NUnit.Framework;
using UnityEngine;
public class SplashScreen : MonoBehaviour
public class SplashScreen : FadeCallback
{
public AudioSource yeah; // Reference to the AudioSource component for playing the sound effect
public MonoBehaviour faderScript; // Reference to the Fader script for handling the fade effect
public Fader faderScript; // Reference to the Fader script for handling the fade effect
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start() { }
@@ -13,13 +12,13 @@ public class SplashScreen : MonoBehaviour
// Update is called once per frame
void Update() { }
void OnFadeStarted()
public override void OnFadeStarted()
{
yeah.PlayDelayed(1.0f);
}
void OnFadeComplete()
public override void OnFadeComplete()
{
faderScript.Invoke("resetFader", 1.1f);
faderScript.resetFader();
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 324e703bfe536666d881917d75b5baf0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+19
View File
@@ -0,0 +1,19 @@
using UnityEngine;
public class EndSplash : FadeCallback
{
public string nextSceneName; // Name of the next scene to load after the splash screen
// 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() { }
public override void OnFadeComplete()
{
UnityEngine.SceneManagement.SceneManager.LoadScene(nextSceneName);
}
}
+8
View File
@@ -0,0 +1,8 @@
using UnityEngine;
public abstract class FadeCallback : MonoBehaviour
{
public abstract void OnFadeStarted();
public abstract void OnFadeComplete();
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fc86a1ba9ae6823f49efc60e21ae4be2
@@ -6,7 +6,7 @@ public class Fader : MonoBehaviour
public bool isFadingIn = true; // Flag to determine if we are fading in or out
public MonoBehaviour callbackScript = null; // Reference to the script that will be called after the fade effect
public FadeCallback callbackScript = null; // Reference to the script that will be called after the fade effect
public bool fadeOnStart = true; // Flag to determine if the fade effect should start automatically on Start
@@ -55,7 +55,7 @@ public class Fader : MonoBehaviour
if (callbackScript != null)
{
// Call the callback method on the specified script
callbackScript.Invoke("OnFadeComplete", 0.0f);
callbackScript.OnFadeComplete();
}
}
else
@@ -66,17 +66,17 @@ public class Fader : MonoBehaviour
}
}
void setFadingIn()
public void setFadingIn()
{
isFadingIn = true;
}
void setFadingOut()
public void setFadingOut()
{
isFadingIn = false;
}
void resetFader()
public void resetFader()
{
startFading = true;
timer = 0.0f;
@@ -84,7 +84,7 @@ public class Fader : MonoBehaviour
if (callbackScript != null)
{
// Call the callback method on the specified script
callbackScript.Invoke("OnFadeStarted", 0.0f);
callbackScript.OnFadeStarted();
}
}
}