// =====

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    public void StartListening(ref InputUIComponent sender)
    {
        //

        if (!isListening)
        {
            //

            targetComponent = sender;
            isListening     = true;
        }
    }
Exemplo n.º 2
0
    // =====

    /// <summary>
    ///
    /// </summary>
    /// <param name="groupName"></param>
    /// <param name="key"></param>
    /// <param name="inputUI"></param>
    public void Initialise(string groupName, Key key, InputUIManager uiManager)
    {
        //

        keyRef = key;

        this.uiManager = uiManager;

        inputInfo = new InputUIInfo(
            groupName,
            key.name,
            key.keyCode.ToString()
            );

        //

        editButton    = GetComponentInChildren <Button>();
        thisComponent = this;

        //

        keyTitle.text = inputInfo.keyTitle;
        keyText.text  = inputInfo.keyName;
    }
    /// <summary>
    ///
    /// </summary>
    private void Update()
    {
        //

        if (isListening && targetComponent != null && Input.anyKeyDown)
        {
            //

            foreach (KeyCode kc in keyCodes)
            {
                if (Input.GetKeyDown(kc))
                {
                    //

                    targetComponent.SetNewKey(kc);

                    //

                    targetComponent = null;
                    isListening     = false;
                }
            }
        }
    }