1234567891011121314151617181920212223242526272829303132 |
- 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;
- }
- }
|