Buttons can only be rectangular?

You could create a custom button with a User Widget and check its alpha.

CustomShapeButton

Follow these steps:

  1. Create User Widget (WBP_CustomShapeButton) and add Image:

  2. Add variables and Event Dispatchers like here:


    ButtonImage - Texture2D
    Normal, Hovered, Pressed - SlateBrush (Instance Editable)
    ButtonRenderTarget - CanvasRenderTarget2D
    IsMouseOver - Bool

  3. Create Material that you draw to Render Target later:

  4. Add Pre-Construct Event to Event Graph.


  5. In the WBP_CustomShapeButton, create a Macro that will check alpha:

  6. Override mouse functions OnMouseButtonDown, OnMouseButtonUp, OnMouseMove:



  7. Override OnMouseLeave event:

Your custom shape button is completed.
Then apply it:

  1. Add the button to your desired widget and fill the style:

Events:

Download Example Project (UE5)

My Products

14 Likes