Added splash screen.

This commit is contained in:
2026-06-24 10:40:48 -04:00
parent f8acbfd084
commit 9f5ec96e18
23 changed files with 1431 additions and 223 deletions
+17
View File
@@ -0,0 +1,17 @@
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");
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9dde416d552cd8958925fd470f36454c
+90
View File
@@ -0,0 +1,90 @@
using UnityEngine;
public class Fader : MonoBehaviour
{
public float fadeDuration = 1.0f; // Duration of the fade effect in seconds
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 bool fadeOnStart = true; // Flag to determine if the fade effect should start automatically on Start
private bool startFading = false; // Flag to start the fade effect
private float timer = 0.0f; // Timer to track the fade progress
private SpriteRenderer sprite = null; // Reference to the component renderer
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
sprite = GetComponent<SpriteRenderer>();
if (fadeOnStart)
{
resetFader();
}
}
// Update is called once per frame
void Update()
{
if (startFading)
{
// Perform fade logic here
if (isFadingIn)
{
// Fade in logic
Color currentColor = sprite.color;
currentColor.a = Mathf.Lerp(0.0f, 1.0f, timer / fadeDuration);
sprite.color = currentColor;
}
else
{
// Fade out logic
Color currentColor = sprite.color;
currentColor.a = Mathf.Lerp(1.0f, 0.0f, timer / fadeDuration);
sprite.color = currentColor;
}
if (timer >= fadeDuration)
{
// Fade effect completed
startFading = false;
if (callbackScript != null)
{
// Call the callback method on the specified script
callbackScript.Invoke("OnFadeComplete", 0.0f);
}
}
else
{
// Increment the timer based on the time elapsed since the last frame
timer += Time.deltaTime;
}
}
}
void setFadingIn()
{
isFadingIn = true;
}
void setFadingOut()
{
isFadingIn = false;
}
void resetFader()
{
startFading = true;
timer = 0.0f;
if (callbackScript != null)
{
// Call the callback method on the specified script
callbackScript.Invoke("OnFadeStarted", 0.0f);
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5620dafb42f459dcfa30ddbbefd24be1
+25
View File
@@ -0,0 +1,25 @@
using NUnit.Framework;
using UnityEngine;
public class SplashScreen : MonoBehaviour
{
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
// 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()
{
yeah.PlayDelayed(1.0f);
}
void OnFadeComplete()
{
faderScript.Invoke("resetFader", 1.1f);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 09d7151b5eeb9b9a0834eb4821a03f34