I don’t know if I’m alone in this, but I’ve worked on a couple of Blueprint systems that need to know the size of meshes in order to work properly. Right now, there seems to be no way to get the dimensions of a static mesh asset without it first existing in the world as a StaticMeshComponent or -Actor.
The workaround I’ve used so far is to add a new static mesh component, calculate the linear sizes from its bounds, and then destroy the component again - but that seems pretty wasteful.
So, here’s my request: Could we perhaps get a function that returns the dimensions of a static mesh asset directly?
That sounds a bit strange.
How do you want to access something that does not exist?
If its a mesh variable, how would you know what mesh its referencing later on?
If its a mesh component, it already exists…
All variables are declared at design time. I dont get what you mean in terms of “creating variables”
Can you give an example use case of what you want to achieve with this and how you would use it.
So far, I havent encountered a scenario that “Get Local Bounds” wouldnt solve…
Local Bounds only works on existing components. Edit to clarify: I would love for it (or something like it) to work with assets, too - i.e., content browser static mesh assets that do not yet exist in game. In my case, I’ve encountered the need for this in two different systems I’ve built already, both meant as a tool for sale on the marketplace - meaning that users would use their own meshes and assets with them, and I don’t know how big they’ll be.
The first case is a system to create networks of spline meshes, with an arbitrary number of sub-meshes. I need to check the size of the main mesh along the forward axis used by the spline, to make sure my auto-tile feature that figures out how many meshes to add over the length of the spline automatically works.
Edited, because it’s 6 am and I haven’t slept yet, so I gave inaccurate info The first case is the only one where it’s actually necessary, in the second case it was just a matter of convenience.
As I mentioned, spawning is not feasible because these things happen at editor time in the construction script.
I also described in the OP that my workaround basically does exactly that, except using “add component” - but it’s an unnecessary and not exactly cheap step to do every time the actor updates, which, when you drag around spline points, is supposed to happen per frame. Especially since the component serves no other function, because the actual system uses spline mesh components, not static mesh components. When you do that to dozens of meshes every frame, it creates some overhead that really shouldn’t be necessary.
I know there’s a workaround, and I’m already using it, as I described in the OP. But I’m basically creating, measuring, and then destroying a component for the sole purpose of getting data that is available in the asset browser directly, and that’s terribly inefficient - and I’ve run into it often enough that it made me consider making this thread, so…
Hi! Not sure how useful this is, but I am only using a staticmesh actor reference in the blueprint, not an actor, and not a component and using the UStaticMesh->CalculateExtendedBounds() and then UStaticMesh->GetBoundingBox(), then I am spawning the mesh component along a spline, so I also can not spawn measure and readjust as my size determines my loop count.
This works for me, no need to spawn and measure but you do need a reference to the static mesh itself somewhere in the blueprint via UStaticMesh.
Side note: SplineMeshClass->GetBounds().BoxExtent for this particular mesh was exactly half the scale of the bounding box, and bounding box also matches the Approx Size values I see on screen when opening the mesh.