Hello,
I was viewing the unity tutorial using the UI tools here:
and while studying it, i see that some changes were made because when i try to wrote this line as in the lesson :
yesButton.onClick.RemoveAllListeners();
with yesButton declared as Button.
if i follow the lesson, when I’m about to type in the editor “yesButton.” I don’t see any onClick events. and i got errors on the line.
What has changed?
To make it clearer, here’s a short version of the full code :
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System.Collections;
public class ModalPanel : MonoBehaviour {
public Text question;
public Image iconImage;
public Button yesButton;
public GameObject modalPanelObject;
private static ModalPanel modalPanel;
// Yes/No/Cancel: A string, a Yes event, a No event and Cancel event
public void Choice (string question, UnityAction yesEvent, UnityAction noEvent, UnityAction cancelEvent) {
modalPanelObject.SetActive (true);
yesButton.onClick.RemoveAllListeners();
yesButton.onClick.AddListener (yesEvent);
yesButton.onClick.AddListener (ClosePanel);/*HERE ARE THE ERRORS : from "onClick, everything is displayed in red, as if the method is not a part of button component*/
}
}