A Quick tip on FSoftObjectPath in Unreal Engine: Sometimes you may need FSoftObjectPaths for “Assets” created at runtime and thus only available in memory and not on disk. I placed “Asset” in quotes cause “Asset” is usually used to refer to a UObject that is also serialized to disk.
Anyway, FSoftObjectPath has a constructor that takes in a UObject. So just do this:
UObject* MyObject=NewObject();
FSoftObjectPath MyObjectPath(MyObject);
NB: Things to keep in mind:
If you’re going to pass your FSoftObjectPath to something, just know that its simply a WeakPointer, so you need to hold “MyObject” as a UProperty() so that it persists throughout the usage lifetime of MyObjectPath.
Just something to think about it, if GC collects the Object, the ObjectPath is still pointing to deleted objects….