Exemple #1
0
    public static void AddGameOption(Action OnComplete, string text = null,
                                     KeyCode code = KeyCode.None, bool destroyOnUse = true)
    {
        foreach (GameOption option in instance.gameOptions)
        {
            if (option.keyCode == code)
            {
                return;
            }
        }

        GameOption go = Instantiate(instance.gameOptionPrefab, instance.transform);

        if (code != KeyCode.None)
        {
            go.image.sprite = GameOption.SpriteFromKeyCode(code);
        }
        go.OnComplete   = OnComplete;
        go.text.text    = text;
        go.destroyOnUse = destroyOnUse;
        go.keyCode      = code;

        instance.gameOptions.Add(go);
        instance.UpdateGameOptions();
    }