Spawn hundreds of random resolution images

HI.

I need to spawn a hundred of planes each with it’s own texture.

I’d like the plane mesh component in my BP to autoscale in construction script, to fit the aspect of the assigned image texture. But I can’t find how to read that info. Ther’s GetWidth and GetHeight nodes to read video media files resolution, but not the equivalent for normal texture assets. AFAIK.

Haw can I do this? It would save me HUGE time setting this up.

Also tryng to find a way to load those textures at runtime, instead of manually create hundreds material instances, but that’s for a different post, I guess.

Any suggestion will be welcome.

I made an ugly and got this:

Currently the 4 images, each with different size, sit in an array. Are we getting close?

4 Likes

No need for a different post for the textures part.

Here is some help. Is not the perfect solution but a workaround…

You must store ALL your textures in an array of class Texture2D somewhere
then you just iterate creating dynamic material instances and replacing the textures
from that array and use @Everynone function for the scale and apply the material.

The thing is how do you create an array with A LOT of textures instead of adding one by one?

this is the workaround:

  1. create an actor just for this purpose and create a Texture2D array inside and tick
    the array as Instance Editable

image

image

throw the actor into the scene and the array will be exposed:

image

  1. create an Editor Utility Widget and just add a button on it:

image

image

in the ‘pressed event’ of the button put this:

  1. right click in the editor utility blueprint icon and run it with the option on the top of the pop up menu:

the widget will run and the window with the button appear

  1. select the actor in the scene, the textures in the browser and PRESS THE BUTTON:

Voila! The array of the actor in the scene has all the textures on it now! :slight_smile:

image

now you can copy that array by right click/copy in the editor

image

  1. go anywhere where you need that array of textures, create another Texture2D array variable, compile and right mouse button paste in the defaults:

image

image

boom! ready to go

Hope it helps!
Best

Dany

5 Likes

You leave a post, go for lunch, and back to the studio all your problems are solved.

Sometimes this forum is awesome.

@Everynone @eldany.uy Thank you!

3 Likes

the utility in action :slight_smile:

how do you create an array with A LOT of textures instead of adding one by one?

Even though it’s probably useless here since you want to load them run-time, this has been a thing as of 4.22 or thereabout:

3 Likes

A video tutorial with background music LOL. This is insane.

Great. I’ll implement runtime loading. That will give the user full flexibility to change content (the images he wants to display) with no intervention on my side. I planned to implement that in further versions, but if it’s so easy I’ll make it in this 1st approach.

I’ve made this function and works perfect.

Edit: needs to activate the BluePrint File Utilities plugin.

Then, once I have an array, @Everynone 's solution for mesh autoscaling and materials, and done.

Thanks you again!

2 Likes