Incidentally i went a completely different way about this from the challenge and invoking and it still works fine.
Not sure if there is anything wrong with doing it this way (I had a crash but i think it was unrelated)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class AreaExit : MonoBehaviour
{
[SerializeField] private string sceneToLoad;
[SerializeField] private string sceneTransitionName;
private float waitToLoadTime = 1f;
private void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.GetComponent<PlayerController>())
{
StartCoroutine(LoadSceneRoutine());
}
}
private IEnumerator LoadSceneRoutine()
{
UIFade.Instance.FadeToBlack();
yield return new WaitForSeconds(waitToLoadTime);
SceneManager.LoadScene(sceneToLoad);
SceneManagement.Instance.SetTransitionName(sceneTransitionName);
}
}
This simply starts the coroutine from the trigger, Does the fade, Waits a second and loads the scene which then triggers the clearfade.
It just seemed a whole lot simpler this way