So I’ve created transition animations between scenes like when opening and closing my main menu from the classic start menu. A black image’s alpha is raised and lowered creating a fade-out effect, so the process is labelled “Fade_Out”. At the same time pressing the “Start Game” button executes the “OpenMenu” variable and immediately switches scenes. How would I go about making the animation play the press of “Start Game” but then transition to the next scene upon it being black?
I’ve already had an attempt at this, but here is the script I’ve been adding onto.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class TitleScreen : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
//create variables for UI options
public void OpenMenu()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void CloseMenu()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0);
}
public void ExitGame()
{
Application.Quit();
Debug.Log("Game has Quit");
}
}
This is my addition to said code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class TitleScreen : MonoBehaviour
{
public Animator animator;
public object StartGame { get; private set; }
public object QuitGame { get; private set; }
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update() {
if (Input.GetButton(string, StartGame))
{
;
}
{
FadeToMenu(1);
}
}
public void FadeToMenu (int 1)
{
animator.SetTrigger("FadeIn");
}
//create variables for UI options
public void OpenMenu()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void CloseMenu()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0);
}
public void ExitGame()
{
Application.Quit();
Debug.Log("Game has Quit");
}
}
Any help at all would be incredibly helpful as I want to stop tweaking the UI.