using System;
using System.Collections.Generic;
using UnityEngine;

namespace Leap.Unity
{
	public class KeyEnableBehaviors : MonoBehaviour
	{
		private void Update()
		{
			if (this.unlockHold != KeyCode.None && !Input.GetKey(this.unlockHold))
			{
				return;
			}
			if (Input.GetKeyDown(this.toggle))
			{
				foreach (Behaviour behaviour in this.targets)
				{
					MonoBehaviour monoBehaviour = (MonoBehaviour)behaviour;
					monoBehaviour.enabled = !monoBehaviour.enabled;
				}
			}
		}

		public List<Behaviour> targets;

		[Header("Controls")]
		public KeyCode unlockHold;

		public KeyCode toggle = KeyCode.Space;
	}
}
