I have just started working with Unity, so I’m experiencing all the thrills and joy of learning a new programming suite from the ground up. All I want to do is create at OnClick function and link it to my button. Here is the code I’ve got:
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class btnSceneSelect : MonoBehaviour
{
public void LoadSceneSelect ()
{
SceneManager.LoadScene( 1 );
}
}
Here is a screenshot of the LoadSceneSelect
function NOT appearing for selection for use with the OnClick
event. The only option that appears under Monoscript is “string name”:
I think we can all agree that LoadSceneSelect
is a public void
function with no parameters.
I would appreciate any insight that could be offered. Thank you!
I imagine it should also be recommended that this "attached GameObject" be an EventsSystem. I take it that's what it's there for? Thanks!
– JuneberryAlso the method needs to have zero or one parameter, or it will not show up.
– GaribaldYou can indeed attach it to the button itself and it works fine.
– Seato