Reputation: 11
Unity has a component called Button as part of its UI system which you can use to subscribe on-click events to it through the inspector which is incredibly useful.
However, when projects get larger, I run into trouble in many situations:
What are some ways I can work around the problems I've listed above?
Upvotes: 0
Views: 3098
Reputation: 4266
Inject event functions inside the code:
public Button playButton; // set button in inspector
public void Start()
{
playButton.onClick.AddListener(() =>
{
transform.position = point1;
// do something..
});
}
Upvotes: 1