I would like to ask you how to make the button round or is there a function that can make the rectangular image round and make the excess part transparent!

  • If there are Settings or ready-made functions, it’s fine, if not, it doesn’t matter I’ll figure it out
  • Hope to get help thanks!

You can use an image to make a round button.
CustomBackground = True
URL = image

regards
Didi

You must use an image with transparent parts.

Indeed the most straightforward and advised approach to have a button with rounded corners is just to apply on the button images with rounded corners already transparent.

You can configure the TCastleButton.CustomBackgroundNormal and related properties to use custom images on a button, and you can configure ProtectedSides within each image to even make the button “resizeable with decent look” using 9-slices algorithm.

@Didi Already gave a nice screenshot, I’m adding another :slight_smile: It’s from the examples/component_gallery/ in CGE sources.

If you really really need to add transparency at runtime, it is possible (by either preprocessing the image (editing TCastleImage alpha channel after loading it from disk) or by assigning a custom shader that makes corner transparent (use TCastleImagePersistent.CustomShader)). But in normal cases, it’s not worth doing that – you would have to write code to do this. And preprocessing image would take time at loading. In normal cases, it’s straightforward to just make corners transparent in GIMP or other 2D graphic application.