Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

Discussion in 'Scripting' started by Mehdi85, Jul 28, 2020.

  1. Mehdi85

    Mehdi85

    Joined:
    Apr 23, 2020
    Posts:
    7
    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

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Video;
    5. using UnityEngine.SceneManagement;
    6.  
    7. public class VideoPlayer : MonoBehaviour
    8. {
    9.     public void Start()
    10.     {
    11.         GameObject camera = GameObject.Find("Main Camera");
    12.  
    13.         var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer>();
    14.  
    15.         videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraNearPlane;
    16.  
    17.  
    18.         videoPlayer.url = "Assets/VideoAssets/intro.mp4";
    19.  
    20.         videoPlayer.isLooping = false;
    21.  
    22.         videoPlayer.Play();
    23.  
    24.         videoPlayer.loopPointReached += EndReached;
    25.  
    26.     }
    27.  
    28.     public void EndReached(UnityEngine.Video.VideoPlayer vp)
    29.     {
    30.         UnityEngine.SceneManagement.SceneManager.LoadScene("truckSeq");
    31.     }
    32. }
    33.  
    34. public abstract class loadTruckSeq : MonoBehaviour
    35. {
    36.     public VideoPlayer videoPlayer;
    37.  
    38.     public abstract void EndReached();
    39. }

    And here is the button script:

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.Diagnostics;
    5. using UnityEngine;
    6. using UnityEngine.SceneManagement;
    7. using UnityEngine.Video;
    8. using Debug = UnityEngine.Debug;
    9.  
    10.  
    11. public class loadTruckButton : loadTruckSeq
    12. {
    13.     public override void EndReached()
    14.     {
    15.         videoPlayer.EndReached();
    16.  
    17.     }
    18. }
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,011
    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.
     
  3. Mehdi85

    Mehdi85

    Joined:
    Apr 23, 2020
    Posts:
    7
    Thanks I passed null and it worked, but it ended up not being fit for purpose what I want to do in the end.
     
unityunity