Manual

UIButton

Description

The UIButton is a core component in the DoozyUI system. It contains all the logic needed for a button to work and behave in various ways in order to create complex UI interactions.

Static Properties

  • public static string BackButtonName – Default UIButton button name for a ‘Back’ button

  • public static string CustomButtonCategory – Default UIButton custom button category name

  • public static string DefaultButtonCategory – Default UIButton button category name

  • public static string DefaultButtonName – Default UIButton button name

  • public static Action<UIButton, UIButtonBehaviorType> OnUIButtonActionAction invoked whenever a UIButtonBehavior is triggered

Properties

  • public Button Button – Reference to the Button component

  • public CanvasGroup CanvasGroup – Reference to the CanvasGroup component

  • public bool HasLabel – If TargetLabel.None -> Returns FALSE. If TargetLabel.Text and TextLabel != null -> Returns TRUE. If TargetLabel.TextMeshPro and TextMeshPro support is enabled and TextMeshProLabel != null -> Returns TRUE.

  • public bool Interactable – Returns TRUE if the Button component is interactable. This also toggles the interactability of this UIButton

  • public bool IsBackButton – Returns TRUE if this UIButton has the ‘Back’ button name

  • public bool IsSelected – Returns TRUE if this UIButton is selected, by checking the EventSystem.current.currentSelectedGameObject

  • public bool UpdateStartValuesRequired – If TRUE, the start values get updated when the next interaction happens

Public Variables

  • public bool AllowMultipleClicks – If TRUE, this button can be spam clicked and it won’t get disabled. If FALSE, after each click, this button will get disabled for DisableButtonBetweenClicksInterval value

  • public string ButtonCategory – UIButton category name

  • public string ButtonName – UIButton button name

  • public SingleClickMode ClickMode – [OnClick Only] Determines if on click is triggered instantly or after it checks if it’s a double click or not. Depending on your use case, you might need the Instant or Delayed mode. Default is set to Instant

  • public bool DeselectButtonAfterClick – If TRUE, after this button has been clicked, double clicked or long clicked, will get automatically deselected

  • public float DisableButtonBetweenClicksInterval – If AllowMultipleClicks is FALSE, then this interval determines for how long this button gets disabled after each click, double click or long click

  • public float DoubleClickRegisterInterval – [OnDoubleClick Only] Time interval used to register a double click. This is the time interval calculated between two sequential clicks to determine if either a double click, or two separate clicks occurred

  • public InputData InputData – Allows the button to react to keys or virtual buttons (only when selected)

  • public float LongClickRegisterInterval – [OnLongClick Only] Time interval used to register a long click. This is the time interval a button has to be pressed down to be considered a long click

  • public UIButtonBehavior OnPointerEnter – Behavior when the pointer enters (hovers in) over the button’s area

  • public UIButtonBehavior OnPointerExit – Behavior when the pointer exits (hovers out) the button’s area (happens only after OnPointerEnter)

  • public UIButtonBehavior OnPointerDown – Behavior when the pointer is down over the button

  • public UIButtonBehavior OnPointerUp – Behavior when the pointer is up over the button (happens only after OnPointerDown)

  • public UIButtonBehavior OnClick – Behavior when the pointer performs a click over the button

  • public UIButtonBehavior OnDoubleClick – Behavior when the pointer performs a double click over the button

  • public UIButtonBehavior OnLongClick – Behavior when the pointer performs a long click over the button

  • public UIButtonBehavior OnSelected – Behavior when the button gets selected

  • public UIButtonBehavior OnDeselected – Behavior when the button gets deselected

  • public UIButtonLoopAnimation NormalLoopAnimation – Loop animation triggered when the button is not selected (in idle mode)

  • public UIButtonLoopAnimation SelectedLoopAnimation – Loop animation triggered when the button gets selected (happens only after OnSelected UIButtonBehavior has bee triggered)

  • public TargetLabel TargetLabel – Determines what type of label this button has

  • public Text TextLabel – Reference to the Text component used as a label for this button

  • public TextMeshProUGUI TextMeshProLabel – Reference to the TextMeshProUGUI component used as a label for this button. Available only if TextMeshPro support is enabled

Public Methods

  • public void EnableButton() – Sets Interactable to TRUE

  • public void ExecutePointerEnter(bool debug = false) – Executes OnPointerEnter actions, if enabled

  • public void ExecutePointerExit(bool debug = false) – Executes OnPointerExit actions, if enabled

  • public void ExecutePointerDown(bool debug = false) – Executes OnPointerDown actions, if enabled

  • public void ExecutePointerUp(bool debug = false) – Executes OnPointerUp actions, if enabled

  • public void ExecuteClick(bool debug = false) – Executes OnClick actions, if enabled

  • public void ExecuteDoubleClick(bool debug = false) – Executes OnDoubleClick actions, if enabled

  • public void ExecuteLongClick(bool debug = false) – Executes OnLongClick actions, if enabled

  • public void ExecuteOnButtonSelected(bool debug = false) – Executes OnSelected actions, if enabled

  • public void ExecuteOnButtonDeselected(bool debug = false) – Executes OnDeselected actions, if enabled

  • public void DeselectButton() – Deselects this button from the EventSystem (if selected)

  • public void DeselectButton(float delay) – Deselects this button from the EventSystem (if selected), after a set delay

  • public void DisableButton() – Sets Interactable to FALSE

  • public void DisableButton(float duration) – Disables the button for a set time duration

  • public void LoadPresets() – Loads all the preset animations, that are set to be loaded at runtime, for all the enabled behaviors

  • public void NotifySystemOfTriggeredBehavior(UIButtonBehaviorType behaviorType) – Sends an UIButtonMessage notifying the system that an UIButtonBehavior has been triggered

  • public void SelectButton() – Selects this button in the EventSystem

  • public void SetLabelText(string text) – If this UIButton has a label referenced, its text will get updated to the given text value

  • public void StartNormalLoopAnimation() – Starts playing the normal loop animation

  • public void StartSelectedLoopAnimation() – Start playing the selected loop animation

  • public void StopNormalAnimation() – Stops playing the normal loop animation

  • public void StopSelectedAnimation() – Stop playing the selected loop animation