TextureButton won't allow PNG mask

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

No matter how hard I try, I can’t load a black and white image to the Click Mask of a TextureButton. I have dragged a PNG but it won’t take it. I have clicked “Load” and I can select the PNG, but when I press Open, the Click Mask stays

Is there a bug with this right now?

thx for advic

Rejio | 2022-09-28 16:42

:bust_in_silhouette: Reply From: ondesic

Here is an answer to my own question. There is something definitely wrong. You should be able to drag a PNG over to the property and just have it work.
BUT there are 2 work around I have found. One is to use code, the other is:

  1. Select the PNG you want as a Mask.
  2. Find the “Import” tab and select it.
  3. There is a drop down menu under “Import As”
  4. Select “Bitmap”
  5. The settings should be “Black & White”
  6. Now click “Reimport”

You now should be able to drag the PNG file over into the “Click Mask” property.

I hope this gets fixed in the future.

I agree there’s a problem with using TextureButton masks. In Godot 3.1.1 reimporting the mask closes and restarts the entire editor !

I also tried using a black and white jpg image as a mask, but that didn’t work either unless you reimport …

@ondesic : thanks for the workaround ! I wouldn’t have thought about doing that.

siska | 2019-05-28 13:53

“Black & White” works if you have a black background. Alternately, you can use “Alpha” to make your mask off the alpha channel if your background is transparent.

Strangely, you cannot make a new “BitMap” resource and load the image into that. The BitMap resource has no way to load a file.

CharlesMerriam | 2020-10-21 17:58

Thanks so much I was very confused by the texturebutton bitmap thing.

lordfarkwad | 2021-02-02 01:42