//private Pooling.Pool<ButtonAction> buttonActionPool;


    /// <summary>
    /// Adds an action.
    /// </summary>
    /// <param name="iconPreset">Icon preset.</param>
    /// <param name="actionName">Action name.</param>
    public void AddAction(GamePadIcon iconPreset, string actionName)
    {
        //ButtonAction ba = buttonActionPool.PopFromPool(Vector3.zero, Quaternion.identity);
        ButtonAction ba = Instantiate(buttonActionPrefab);

        ba.actionSprite.ChangeIcon(iconPreset);
        ba.actionLabel.text = actionName;
        ba.transform.SetParent(ButtonsContainer.transform, false);
        // -
        buttonActions.Add(ba);
    }
Beispiel #2
0
 public void ChangeIcon(GamePadIcon newIconType)
 {
     image.sprite = iconSet.GetIcon(newIconType);
 }
    public Sprite GetIcon(GamePadIcon iconType)
    {
        switch (iconType)
        {
        case GamePadIcon.ActionRight:
            return(ActionRight);

        case GamePadIcon.ActionLeft:
            return(ActionLeft);

        case GamePadIcon.ActionDown:
            return(ActionDown);

        case GamePadIcon.ActionUp:
            return(ActionUp);

        case GamePadIcon.ActionRightDown:
            return(ActionRightDown);

        case GamePadIcon.ActionDownLeft:
            return(ActionDownLeft);

        case GamePadIcon.ActionLeftUp:
            return(ActionLeftUp);

        case GamePadIcon.ActionUpRight:
            return(ActionUpRight);

        case GamePadIcon.LeftTrigger1:
            return(LeftTrigger1);

        case GamePadIcon.RightTrigger1:
            return(RightTrigger1);

        case GamePadIcon.LeftTrigger2:
            return(LeftTrigger2);

        case GamePadIcon.RightTrigger2:
            return(RightTrigger2);

        case GamePadIcon.AnalogLeft_Press:
            return(AnalogLeft_Press);

        case GamePadIcon.AnalogRight_Press:
            return(AnalogRight_Press);

        case GamePadIcon.AnalogRight:
            return(AnalogRight);

        case GamePadIcon.AnalogLeft:
            return(AnalogLeft);

        case GamePadIcon.DPadRight:
            return(DPadRight);

        case GamePadIcon.DPadLeft:
            return(DPadLeft);

        case GamePadIcon.DPadUp:
            return(DPadUp);

        case GamePadIcon.DPadDown:
            return(DPadDown);

        case GamePadIcon.Start:
            return(Start);

        case GamePadIcon.Select:
            return(Select);

        default:
            return(null);
        }
    }