// Copyright (c) Pixel Crushers. All rights reserved. using UnityEngine; namespace PixelCrushers.DialogueSystem { /// /// Defines an input trigger using a key code and/or button name. The easiest way to bind a key /// to the trigger is to assign a key code. You can also assign a button name defined in /// UnityEngine.InputManager such as "Fire1" or a custom-defined button. /// [System.Serializable] public class InputTrigger { /// /// The key that fires the trigger. /// [Tooltip("This key fires the trigger.")] public KeyCode key = KeyCode.None; /// /// The name of the button defined in UnityEngine.InputManager that fires the trigger. /// [Tooltip("This button fires the trigger. The button name must be defined in your project's Input Settings.")] public string buttonName = string.Empty; /// /// Initializes a new instance of the /// class with no key code or button name. /// public InputTrigger() { } /// /// Initializes a new instance of the /// class with a key code assigned. /// /// /// Key that fires the trigger. /// public InputTrigger(KeyCode key) { this.key = key; } /// /// Initializes a new instance of the /// class with a button name assigned. /// /// /// Name of the button defined in UnityEngine.InputManager that fires the trigger. /// public InputTrigger(string buttonName) { this.buttonName = buttonName; } /// /// Initializes a new instance of the /// class with a key code and button name assigned. /// /// /// Key that fires the trigger. /// /// /// Name of the button defined in UnityEngine.InputManager that fires the trigger. /// public InputTrigger(KeyCode key, string buttonName) { this.key = key; this.buttonName = buttonName; } /// /// Gets a value indicating whether this input trigger has been triggered (i.e., the /// key or button is down). /// /// /// true if this instance is triggered; otherwise, false. /// public bool isDown { get { if (DialogueManager.IsDialogueSystemInputDisabled()) return false; return InputDeviceManager.IsKeyDown(key) || (!string.IsNullOrEmpty(buttonName) && DialogueManager.getInputButtonDown(buttonName)); } } /// @cond FOR_V1_COMPATIBILITY public bool IsDown { get { return isDown; } } /// @endcond } }