Hi,
I am using Events/Delegates for the first time so this will probably be an easy fix for those who use them often. Also, being new to events sorry if I misuse the terminology of event and delegates (I think I’ve done it right, however)
I have a method called ‘FadeIn()’ that I need to call when the scene changes. Through some searching, I believe I can use events and subscribe FadeIn as a delegate to the SceneManager.activeSceneChanged event to accomplish this.
However when I subscribe using the below code:
void OnEnable()
{
SceneManager.activeSceneChanged += FadeIn;
}
void OnDisable()
{
SceneManager.activeSceneChanged -= FadeIn;
}
I get the following error in the console:
Assets/_Scripts/GameManager.cs(96,16): error CS0123: A method or delegate `GameManager.FadeIn()' parameters do not match delegate `UnityEngine.Events.UnityAction<UnityEngine.SceneManagement.Scene,UnityEngine.SceneManagement.Scene>(UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.Scene)' parameters
Which I find strange because I’m not trying to pass any parameters through FadeIn, so I’m guessing activeSceneChanged needs parameters and I’m struggling to find anything about them in the documentation.
Has anybody come across this before and could somewhere else in my code be causing these lines to throw this error?