Im trying to Fade to either Black or white between scenes using animations and i can seem to fad in but as soon as i try to add the fade out script its seems to break the entire script rendering it completly useless even afrer removing the extra lines of script so if someone could help me out id appreciate it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class goback : MonoBehaviour
{
private void OnTriggerStay(Collider sceneTrigger)
{
if (Input.GetKey(KeyCode.E))
{
if (sceneTrigger.CompareTag("Player"))
{
SceneManager.LoadScene("Two", LoadSceneMode.Single);
SceneManager.UnloadSceneAsync("Main");
}
}
}
}
actually check this one out. i got it after a few hours of winging the hell out of it. Thanks for the help though.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class FadeBlack : MonoBehaviour
{
public int rendex;
public string levelname;
public int index;
public string unloadname;
public Image Black;
public Animator anim;
private void OnTriggerStay(Collider other)
{
if (Input.GetKey(KeyCode.E))
{
if (other.CompareTag("Player"))
{
StartCoroutine(Fading());
}
}
}
IEnumerator Fading()
{
anim.SetBool("Fade", true);
yield return new WaitUntil(() => Black.color.a == 1);
{
SceneManager.LoadScene(rendex, LoadSceneMode.Single);
SceneManager.UnloadSceneAsync(index);
}
}
}