示例#1
0
    private void SetUpControlsMenu()
    {
        keybindButtons = new List <KeybindButton>();

        int   controlsCount = System.Enum.GetValues(typeof(GameControls)).Length;
        float yScale        = keybindButtonPrefab.GetComponent <RectTransform>().sizeDelta.y;

        contentWindow.sizeDelta = new Vector2(contentWindow.sizeDelta.x, (controlsCount - 1) * yScale); // count - 1 so ESCAPE can't be rebound

        for (int i = 0; i < controlsCount - 1; i++)
        {
            GameControls  c             = (GameControls)i;
            KeybindButton keybindButton = Instantiate(keybindButtonPrefab, contentWindow);
            keybindButton.SetUp(-yScale * i, c, KeybindingController.GetKeybindName(c));

            keybindButtons.Add(keybindButton);
        }

        uiBlocker.SetActive(false);
        keybindExplanation.SetActive(false);
    }