Unity 5.6: OnClick() not working...

Hi.

I’m having a VERY frustrating issue with a main menu I’m creating… below is a link to the problem in the LinusTechTips forum (Which is great BTW). :

Or you can just read it here:

I got a problem.

Im making a menu for a game in unity 5.6. I am using this tutorial:

In this part of the video:

He adds the script, hits a dropdown menu and then goes LoadSceneOnClick > LoadByIndex(int), and then sets “LoadByIndex” to 1. When I hit the dropdown menu, the only option is “MonoScript”, and then “Sting name”:

Even if I input “1” into the box, nothing happens when I play the scene. Here is my script:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LoadSceneOnClick : MonoBehaviour {

public void LoadByIndex(int sceneIndex)
{
SceneManager.LoadScene (sceneIndex);
}
}

Using unity 5.6. HOW TO FIX!?!?!? Getting frustrated.

All help appreciated!!!

The problem is that you have to add the script to a gameobject in the scene (any one will do). Then, you add that same gameobject to the spot where you previously added the script. This is a small bit of knowledge that virtually everyone has to learn when they start. :slight_smile:
Then, you will see the drop down menu showing you the right information (whatever’s in the video).

1 Like

THANK YOU! IT WORKED!!

WHAT THE HECK. Thank you so much. This is the kind of subtle thing that could cause people (me, at least!) to just bounce off Unity forever. Is there no way they could nudge us to do that a bit more clearly inside the editor??