Search Unity

Trying to make button trigger function, but it shows as "missing" even though it is there.

Discussion in 'Scripting' started by kikendo, Sep 21, 2017.

  1. kikendo

    kikendo

    Joined:
    Jul 19, 2017
    Posts:
    61
    This one is a head-scratcher for me.

    I have a button that loads a level.
    My level loading script is simple:
    Code (CSharp):
    1. public class LoadScene : MonoBehaviour {
    2.  
    3.     public static void LoadLevel (int level) {
    4.         SceneManager.LoadScene (level,LoadSceneMode.Single);
    5.     }
    6.  
    7. }
    I assign this script to a SceneLoader object, and then I try to activate this through the button. HEre's what happens:


    Why is this showing as "Missing" if it is right there and selected?
    Of course, it doesn't work.

    This was working before when I was calling the same function but without a parameter. Now that I added the parameter, it does this. But if I remove the parameter, it still shows as "Missing".

    [edit] I changed the method's name to "LoadALevel" in case it was conflicting with the deprecated method Application.LoadLevel, still the same problem.
     
    Last edited: Sep 21, 2017
  2. Errorsatz

    Errorsatz

    Joined:
    Aug 8, 2012
    Posts:
    555
    kikendo likes this.
  3. kikendo

    kikendo

    Joined:
    Jul 19, 2017
    Posts:
    61
    Aw damnit. This is really annoying, because I wanted to access this method by script too.
    I guess I'll have to make an intermediary script that calls the other method. What a pain!!!

    Thanks for your help!