How can I fix this "There is no argument given that corresponds to the required formal parameter"

Hi all,

I’m setting up a video player with EndReached method to check if the end of the clip is reached and I will need to assign this to a button which I am linking to the second script below. But I’m getting this error:

Assets\Scenes\loadTruckButton.cs(15,21): error CS7036: There is no argument given that corresponds to the required formal parameter ‘vp’ of ‘VideoPlayer.EndReached(VideoPlayer)’

Any help would be much appreciated.

Here is the video player script with the EndReached method

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.SceneManagement;

public class VideoPlayer : MonoBehaviour
{
    public void Start()
    {
        GameObject camera = GameObject.Find("Main Camera");

        var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer>();

        videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraNearPlane;


        videoPlayer.url = "Assets/VideoAssets/intro.mp4";

        videoPlayer.isLooping = false;

        videoPlayer.Play();

        videoPlayer.loopPointReached += EndReached;

    }

    public void EndReached(UnityEngine.Video.VideoPlayer vp)
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("truckSeq");
    }
}

public abstract class loadTruckSeq : MonoBehaviour
{
    public VideoPlayer videoPlayer;

    public abstract void EndReached();
}

And here is the button script:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Video;
using Debug = UnityEngine.Debug;


public class loadTruckButton : loadTruckSeq
{
    public override void EndReached()
    {
        videoPlayer.EndReached();

    }
}

Your videoPlayer.EndReached requires a videoplayer reference to be passed to it and you aren’t doesn’t so. Since you aren’t doing anything with the reference, you could just put null as the passed parameter.

Thanks I passed null and it worked, but it ended up not being fit for purpose what I want to do in the end.