void Update() { PlayerControls controls = PlayerControls.Get(player_id); if (!controls.IsGamePad()) { return; } if (controls.IsUIPressLeft()) { Navigate(Vector2.left); } else if (controls.IsUIPressRight()) { Navigate(Vector2.right); } else if (controls.IsUIPressUp()) { Navigate(Vector2.up); } else if (controls.IsUIPressDown()) { Navigate(Vector2.down); } //Stop navigate if out of focus UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel(); if (selected_panel != null && !selected_panel.IsVisible()) { StopNavigate(); } else if (selected_panel != null && selected_panel.GetSelectSlot() != null && !selected_panel.GetSelectSlot().IsVisible()) { StopNavigate(); } //Controls if (controls.IsPressUISelect()) { OnPressSelect(); } if (controls.IsPressUIUse()) { OnPressUse(); } if (controls.IsPressUICancel()) { OnPressCancel(); } if (controls.IsPressAttack()) { OnPressAttack(); } }
public void NavigateTo(UISlot slot, Vector2 dir) { UISlotPanel panel = slot?.GetParent(); if (panel != null && panel.IsVisible()) { panel.Focus(); panel.selection_index = slot.index; } else { Navigate(panel, dir); } }
public bool IsVisible() { return(gameObject.activeSelf && (parent == null || parent.IsVisible())); }