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
+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);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9dde416d552cd8958925fd470f36454c
+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
+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 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
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.OnFadeComplete();
}
}
else
{
// Increment the timer based on the time elapsed since the last frame
timer += Time.deltaTime;
}
}
}
public void setFadingIn()
{
isFadingIn = true;
}
public void setFadingOut()
{
isFadingIn = false;
}
public void resetFader()
{
startFading = true;
timer = 0.0f;
if (callbackScript != null)
{
// Call the callback method on the specified script
callbackScript.OnFadeStarted();
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5620dafb42f459dcfa30ddbbefd24be1