protected void Awake()
    {
        if (interactions.Length == 0)
        {
            useDelegate   = DefaultUse;
            breakDelegate = DefaultBreak;
        }
        else
        {
            IUseInteraction   u;
            IBreakInteraction b;

            foreach (MonoBehaviour interaction in interactions)
            {
                if (interaction is IUseInteraction)
                {
                    u            = (IUseInteraction)interaction;
                    useDelegate += u.Use;
                }
                if (interaction is IBreakInteraction)
                {
                    b              = (IBreakInteraction)interaction;
                    breakDelegate += b.Break;
                }
            }
        }
    }
 /// <summary>
 /// Bind delegates to particular make/break input event.
 /// </summary>
 /// <param name="deviceNumber">Device number to bind.</param>
 /// <param name="objectId">Device object to bind to.  E.g., GamePads have thumb sticks, buttons, and triggers, which 
 /// have id's corresponding to XGamePadDevice.GamePadObjects enum values.</param>
 /// <param name="makeDelegate">Delegate to invoke on make events.</param>
 /// <param name="breakDelegate">Delegate to invoke on break events.</param>
 /// <returns>True if binding was succesful.</returns>
 public bool BindCommand(int deviceNumber, int objectId, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
 {
     return BindCommand(deviceNumber, objectId, TorqueInputDevice.Action.None, makeDelegate, breakDelegate);
 }
 /// <summary>
 /// Bind delegates to particular make/break input event.
 /// </summary>
 /// <param name="deviceName">Name of device to bind to, e.g. "gamepad1", "mouse0", "keyboard0".</param>
 /// <param name="inputObject">Name of input object to bind to, e.g. "ThumbStickX", "LeftTriggerButton".</param>
 /// <param name="makeDelegate">Delegate to invoke on make events.</param>
 /// <param name="breakDelegate">Delegate to invoke on break events.</param>
 /// <returns>True if binding is successful.</returns>
 public bool BindCommand(String deviceName, String inputObject, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
 {
     return BindCommand(deviceName, inputObject, TorqueInputDevice.Action.None, makeDelegate, breakDelegate);
 }
        /// <summary>
        /// Bind delegates to particular make/break input event.
        /// </summary>
        /// <param name="deviceName">Name of device to bind to, e.g. "gamepad1", "mouse0", "keyboard0".</param>
        /// <param name="inputObject">Name of input object to bind to, e.g. "ThumbStickX", "LeftTriggerButton".</param>
        /// <param name="modifier">Restrict binding to be in effect only when given modifier is present.  Valid modifiers are 
        /// Shift, Ctrl, LeftClick, MiddleClick, RightClick</param>
        /// <param name="makeDelegate">Delegate to invoke on make events.</param>
        /// <param name="breakDelegate">Delegate to invoke on break events.</param>
        /// <returns>True if binding is successful.</returns>
        public bool BindCommand(String deviceName, String inputObject, TorqueInputDevice.Action modifier, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
        {
            int deviceNumber = InputManager.Instance.FindDevice(deviceName);
            if (deviceNumber == -1)
                return false;

            TorqueInputDevice device = InputManager.Instance.GetDevice(deviceNumber);
            int objectId = device.GetObjectId(inputObject);
            if (objectId == -1)
                return false;

            return BindCommand(deviceNumber, objectId, modifier, makeDelegate, breakDelegate);
        }
        /// <summary>
        /// Bind delegates to particular make/break input event.
        /// </summary>
        /// <param name="deviceNumber">Device number to bind.</param>
        /// <param name="objectId">Device object to bind to.  E.g., GamePads have thumb sticks, buttons, and triggers, which 
        /// have id's corresponding to XGamePadDevice.GamePadObjects enum values.</param>
        /// <param name="modifier">Restrict binding to be in effect only when given modifier is present.  Valid modifiers are 
        /// Shift, Ctrl, LeftClick, MiddleClick, RightClick</param>
        /// <param name="makeDelegate">Delegate to invoke on make events.</param>
        /// <param name="breakDelegate">Delegate to invoke on break events.</param>
        /// <returns>True if binding was succesful.</returns>
        public bool BindCommand(int deviceNumber, int objectId, TorqueInputDevice.Action modifier, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
        {
            if (deviceNumber < 0 || deviceNumber >= InputManager.Instance.GetNumDevices())
                return false;
            TorqueInputDevice device = InputManager.Instance.GetDevice(deviceNumber);
            if (!device.IsValidObject(objectId))
                return false;

            InputNode node = new InputNode();
            node.DeviceNumber = deviceNumber;
            node.ObjectId = objectId;
            node.Modifier = modifier;
            node.Flags = InputNode.ActionFlags.BindCmd;
            node.DeadZoneBegin = 0.0f;
            node.DeadZoneEnd = 0.0f;
            node.ScaleFactor = 1.0f;
            node.MoveIndex = -1;
            node.MakeDelegate = makeDelegate;
            node.BreakDelegate = breakDelegate;
            _SetInputNode(deviceNumber, objectId, modifier, ref node);
            _currentBindIndex = -1;

            return true;
        }
 public static void SetBreakDelegate(BreakDelegate breakDelegate)
 {
     s_m_breakDelegate = breakDelegate;
 }