/// <summary> /// Adds a click listener to the button component /// </summary> /// <param name="screen">Screen name</param> private void AddClickListener(ScreenControl.SCREENS screen) { //Get the button component of this game object Button btn = gameObject.GetComponent <Button>(); //Calls the TaskOnClick/TaskWithParameters method when the button is clicked btn.onClick.AddListener(() => { //Enable the desired screen screensControl.EnableScreen(screen); }); }
/// <summary> /// Adds a click listener to the button component /// </summary> /// <param name="screen">Screen name</param> private void AddClickListener(ScreenControl.SCREENS screen) { //Get the button component of this game object Button btn = gameObject.GetComponent <Button>(); //Calls the TaskOnClick/TaskWithParameters method when the button is clicked btn.onClick.AddListener(() => { //If the error message is inactive if (!lengthErrorMessage.IsActive()) { //Enable the desired screen screensControl.EnableScreen(screen); } }); }