Something like this?
If the asset contained within the package has a different name, the “divide by 2” won’t work and you’ll have to find the “.” in the name and take what’s after it…
Clever reduction of pathname, but I am trying to go from the string name back to the object. I’m building a map, but am surprised it’s not built in.
Thanks all for the help.
Are you creating an object at runtime, saving its name and then trying to find it again by name? That’s rather unusual, but there are built in functions in C++ like FindObject. You can also look into FSoftObjectPath, TSoftObjectPtr or TWeakObjectPtr which can all store a reference to an object either by path or by index and then easily convert it back to the object (if it still exists)
It’s really early for you to start with “newbie question” and 2 posts later claim how weird that it’s not built-in.
You haven’t explained at all what you are trying to achieve. What kind of object, where do you have the name from. None of this is explained, so since no one can really know what you meant by all of this, you cannot be surprised you haven’t found the solution yet.
Why would you even want to use mapping like that etc.
Hi, Could I use this structure to identify folder paths? I want to alert a warning if any used assets come from a folder named anything like “test” folder. If it has “test” in its name.
Hi, you could do a simple “contains” on the whole folder to check for a test string like below. If you were wanting to test for a folder which was just called test, you can look for “/test/”:
Thanks for the solution!
I managed to make a small improvement to it.
The issue:
If you have in the same folder a file named “Strawberry” and a file named “StrawberryYummy” both of these will pass through the filter part and undesired results may happen after.
There may be even bigger weird stuff happening if these files have a folder above them called “Strawberry” but i didn’t test this.
To remove this issue, it seems to be enough to just add ‘/’ at the start of the substring, and ‘.’ at the end of the substring.
I tried and failed to make even bigger improvements.
I will document them here hoping someone manages to complete my work.
The idea was to switch the plural ‘Get AssetS by Path’ to the singular ‘Get Asset by Object Path’
This node only takes in one path right to the asset itself, so it should be more efficient by not having to go through the whole folder only to discard all files within that folder except for one.
I could not get it to work however.
In the picture i have my attempt with both nodes, with printouts showing the results and the differences in them.
I believe the issue lies within the difference of the ‘Asset Class Path’ in the AssetData struct.
Therefore i tried to manually edit this struct, but this proved to be impossible in the normal ways one edits a struct, see the difference at the bottom pictures.
I got “Get Asset by Object Path” working. Your image is a little blurry, so I can’t tell what you plugged in for the Object Path, but after some trial and error here is what worked.
Using the clean filename successfully returns the asset:
/Game/…/AssetName.AssetName
Using the base filename with or without .uasset appended fails to return the asset:
/Game/…/AssetName
/Game/…/AssetName.uasset