Files
Barrack-Unity/Assets/Scripts/Intro/Intro.cs
T

45 lines
1.1 KiB
C#
Raw Normal View History

2026-06-24 14:01:18 -04:00
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
2026-08-04 00:44:32 -04:00
void Start() { }
2026-06-24 14:01:18 -04:00
// Update is called once per frame
void Update() { }
public override void OnFadeStarted()
{
playAudioCoroutine = PlayAudioThenActivateGameObject();
StartCoroutine(playAudioCoroutine);
}
public override void OnFadeComplete() { }
2026-07-28 01:06:41 -04:00
public void ForceStopAudioCoroutine()
2026-06-24 14:01:18 -04:00
{
if (playAudioCoroutine != null)
{
StopCoroutine(playAudioCoroutine);
playAudioCoroutine = null;
}
music.Stop();
2026-07-28 01:06:41 -04:00
faderScript.Invoke("ResetFader", 0.0f);
2026-06-24 14:01:18 -04:00
}
private IEnumerator PlayAudioThenActivateGameObject()
{
music.Play();
yield return new WaitUntil(() => music.time >= music.clip.length);
2026-07-28 01:06:41 -04:00
faderScript.Invoke("ResetFader", 0.0f);
2026-06-24 14:01:18 -04:00
}
}