Skip to content

Instantly share code, notes, and snippets.

@aesthezel
Created May 21, 2021 13:20
Show Gist options
  • Save aesthezel/e6d1e00b4633ccb34b11f311ebc26bf2 to your computer and use it in GitHub Desktop.
Save aesthezel/e6d1e00b4633ccb34b11f311ebc26bf2 to your computer and use it in GitHub Desktop.
A Unity UI Button performing another buttons with click on it
using UnityEngine;
using UnityEngine.UI;
public class MasterButton : MonoBehaviour
{
public Button primaryButton;
public Button[] targetButtons;
void Start()
{
primaryButton.onClick.AddListener( () => {
foreach (var button in targetButtons)
{
button.onClick.Invoke();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment