Ejemplo n.º 1
0
    private void AddButtonForKey(string key, bool allowMouse = false)
    {
        if (vertSpace >= rows * verticalSpacing)
        {
            horizSpace += horizontalSpacing;
            vertSpace   = 0f;
        }

        SetButtonGUI sbg = (SetButtonGUI)Instantiate(setButtonPrefab);

        sbg.buttonName              = key;
        sbg.buttonLabel.text        = key + ":";
        sbg.PrimaryLabel.text       = FormatButtonText(cInput.GetText(key, 1));
        sbg.SecondaryLabel.text     = FormatButtonText(cInput.GetText(key, 2));
        sbg.transform.parent        = parentPoint;
        sbg.transform.localPosition = new Vector3(horizSpace, -vertSpace, 0f);
        sbg.transform.localScale    = Vector3.one;

        sbg.PrimaryButton.sendMessage.gameObjectMessage.messageReceiver   = gameObject;
        sbg.SecondaryButton.sendMessage.gameObjectMessage.messageReceiver = gameObject;

        if (allowMouse)
        {
            sbg.allowMouseAxis    = true;
            sbg.allowJoystickAxis = true;
        }

        ButtonClass newButtonClass = new ButtonClass();

        newButtonClass.buttonName = key;
        buttonList.Add(newButtonClass);

        controlButtons.Add(sbg.buttonName, sbg);
        vertSpace += verticalSpacing;
    }
Ejemplo n.º 2
0
    public void ConfirmKeyChange()
    {
        waitingForInput     = null;
        waitForNextKeyPress = false;

        RefreshAllButtons();
    }
Ejemplo n.º 3
0
    public void RevertKeyChange()
    {
        string[] oldString   = oldButtonInfo.Split(new string[] { "||" }, System.StringSplitOptions.None);
        string[] existString = existButtonInfo.Split(new string[] { "||" }, System.StringSplitOptions.None);
        cInput.ChangeKey(currentButtonName, oldString[0], oldString[1]);
        cInput.ChangeKey(existString[0], existString[1], existString[2]);

        waitingForInput     = null;
        waitForNextKeyPress = false;

        RefreshAllButtons();
    }
Ejemplo n.º 4
0
    public void UpdatedKey(string keyName, string prim, string sec)
    {
        int duplicateIndex = CheckDuplicateKey(prim, sec, keyName, waitIndex);

        if (duplicateIndex > -1)
        {
            return; //Wait for confirmation or denial.
        }

        waitingForInput     = null;
        waitForNextKeyPress = false;

        RefreshAllButtons();
    }
Ejemplo n.º 5
0
    public void SetSecondary(GameObject button)
    {
        if (waitForNextKeyPress)
        {
            return;
        }

        waitingForInput   = button.GetComponent <SetButtonGUI>();
        currentButtonName = waitingForInput.buttonName;
        oldButtonInfo     = cInput.GetText(currentButtonName, 1) + "||" + cInput.GetText(currentButtonName, 2);
        waitingForInput.SecondaryLabel.text = "Press any key";
        cInput.ChangeKey(waitingForInput.buttonName, 2, waitingForInput.allowMouseAxis, true, waitingForInput.allowJoystickAxis, true);
        waitIndex           = 2;
        waitForNextKeyPress = true;
    }