﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(Button))]
public class ActionButton : MonoBehaviour
{
	public Action action = null;
	public Button button = null;
	public Text buttonText = null;

	private void Start()
	{
		if (action != null)
		{
			buttonText.text = action.name;
			button.onClick.AddListener(PerformAction);
		}
		else
		{
			Destroy(gameObject);
		}
	}

	private void PerformAction()
	{
		action.Perform();
	}
}
