Can't find a variable that supports images and sprites like native widgets do?

If you use a UMG native “button” or “image”, the dropdown lets you select both images and sprites.

However.. I cannot find a blueprint variable that supports both like this? The only thing that I can find that supports both is “object”, which contains every object obviously (yuck.)

I’m trying to find a solution to either A or B:

A> Find a variable that accepts both. (So that I can select either a sprite or an image at any time.)

or…

B> Find a better method of chopping up a texture atlas into individual textures (NOT sprites.)

I prefer to have all the UI images on 1 large grid inside 1 texture file.. but I guess if neither option works, I’ll have to deal with lots of individual files.

Any thoughts?

Native UMG classes use FSlateBrush which uses a regular UObject for the object you’re referring to (with flags to allow only compatible classes). I suggest either trying Slate Brush as the variable type (and setting the image/sprite inside it) if all you’re going to do with it is plug it into widgets in some way, or just using a Texture variable which will support any images/sprites you throw at it.

Thanks for the feedback, however, using a slate brush as a parameter would be extremely convoluted for a simple texture parameter. I’m trying to reduce future workflow with re-usable widgets that have easy to plug in parameters.

or just using a Texture variable which will support any images/sprites you throw at it.

This is the question I’m asking though. How would you even do that? I can’t find any that support images/sprites at the same time.

Perhaps we’re misunderstanding each other, so just to clarify: you’ve tried the Texture variable type (see image) and it’s incompatible with the things you want to put in it? Could you screenshot the exact types of objects you’re trying to use?

“Texture” does not include sprites. Make a variable, and you’ll only see valid texture assets in the dropdown.

Yet, the native buttons allow both textures and sprites in the dropdown. I’d like a variable that works just like that, which I cannot find.

Ah I see, you’re probably attempting to use the “Paper Sprite” type. (needed specifics because there are a bunch of classes with “sprite” in their name)

Yeah those types (Paper Sprite and Texture, etc.) have no common base, so if you want to accept both you either:

  • need C++ and do the same thing they did with FSlateBrush
  • or just use FSlateBrush instead
  • or use Objects and cast them yourself; you can use the Allowed Classes field to only allow the ones you want, but you’ll still have to cast them before using them (because nodes won’t accept generic Objects)

It’s not a “simple texture” because it’s actually multiple unrelated types, so these options are all there is.

Yes, paper sprite, which the file asset type is declared as:

image

It’s not a “simple texture” because it’s actually multiple unrelated types, so these options are all there is.

Of course they aren’t the same asset type. That’s why I’m asking how to mimic the native widgets which allow both in the object selection dropdown menu for images. I would have thought there would be some parent class for all image types (textures, sprites, etc.) but apparently there isn’t.

I appreciate the help, but none of that info is new to me, and doesn’t really give a simple solution to what I would have thought would already exist.

I’m ready to drop sprites, and manually deal with individual texture files.

What would actually be better, is if there was a way to force specific blueprint variables to only be allowed to look into a specific folder. i.e. making the asset selection dropdown “dummy-proof”, where you only want to see specific images that are located in “UI/buttons”, etc. instead of seeing every texture map in the entire project and needing to know ahead of time what names to look for.

That’s why I’m asking how to mimic the native widgets which allow both in the object selection dropdown menu for images.

Just to clarify (for future readers) - as replied earlier, the native widgets use filtered UObjects wrapped inside FSlateBrush, and these are still available in BPs. For a C++ reference, here’s how they handle the filtered UObject:

image

So it tracks that to get the same behavior in BP you either need casts (same as this C++ implementation), or you need to reuse what they’re using, which is FSlateBrush.

As for the folder filtering - I don’t think there’s support for that in BP, unfortunately.

image

Right, I saw that in the slate brush, and the widget tooltip also states the 3 types allowed. I should have posted that in the first post. I would have thought there would be a native variable to include these types already, since epic uses them in multiple cases.

I should have also mentioned I need an option that is native to UE. The purpose is to make dummy-proof ways to select images. Something that designers or artists would select.

I have the same problem with data assets, where I wish I could narrow down the list of images to only specific folders. So if you only want the image dropdown selector to allow anything that is an icon, but not 3d textures or other textures. I can’t see that being done without modifying engine code? (which I 100% want to avoid.)

The best I can do, is just prefix all UI icons with something that will filter easier. And like I said in the first post, I know about casting to a UObject, but the selection seems messy, and requires you to type in the filter every time you open a dropdown box.

1 Like

Hmm, just in case there’s another misunderstanding, could you doublecheck that making the variable an Object (Soft for example) and adding the allowed classes you want (UPaperSprite and UTexture I guess) actually results in a “messy” user experience? AFAIK it will just cleanly show the allowed classes in the dropdown, the user doesn’t have to do anything else. My concern was with the casting and checks you’ll have to do when you use it, not the user-setting side.

As I said, I need a native UE solution. Custom C++ code will not be viable for this.

I’m unaware of any way to add allowed classes to blueprint variables, unless you have any ideas about this?

If the answer is: there no solution. Then I’m just going to end this, and ditch sprites, and figure out a better naming convention for UI textures.

So there was a misunderstanding! Yes, there is a way, click on the variable and look for this in the details:

Sorry, but I don’t see anything about meta data in variables.

Using v5.5.4 for reference

Did you set the variable type to Object? The Meta category shows for all variables, but the Allowed/Disallowed part (seemingly) only for Objects. Here are some extra images:

Created a new Object variable named NewVar.
image

Clicked on the variable to get its details:

There’s no meta category…

Either its a plugin or some non-default option?

Ah sorry for the confusion - yep, this came with GitHub - DoubleDeez/MDMetaDataEditor: Unreal Engine 5.1+ plugin to enable editing meta data of Blueprint Properties, Functions, and Function and Event Parameters

Yeah, Objects are definitely not a great option for you then. :frowning: