Any way to check of a soft reference path has already been loaded?

I’ve a bunch of extra logic that goes on to keep a reference to some variables that need to be passed to an actor component that’s async loaded using a soft reference class, but I’d like to skip all of that if the actor component has already loaded into memory. Is there no way to check for this or do I just have to keep track of it myself somewhere globally? If I can check that it was already loaded it’d let me skip a bunch of unnecessary processes.

You can ask a soft reference for its target object without trying to load it. If it’s not loaded, that resolve will return none/invalid/nullptr. You can branch on that to do whatever you want for each case.

1 Like

Is there a BP node for that? I’ve read that for C++ you can just check if it’s pending, but I don’t see anything like that in BP.

The node for that is ‘Resolve Soft Reference’ and looks like this:

image

I don’t know about checking if the load is pending in C++, I’ve never done that. Well not exactly. You wouldn’t check if something that you haven’t already requested is loaded. You would do the same sort of thing that you’d do in blueprint:

If the reference already resolves to an object, do the work.
If it doesn’t, request an async load. You can either give that a callback, or add one to the returned stream handle or store the stream handle. Once you have that handle you can check if the entire request is complete (not individual files).

The blueprint nodes that are available hide the handle behavior from you and just give you the callback through the ‘Completed’ execution pin.

But really, you might just be making extra work for yourself. The async loading blueprint node should basically already do all this for you one way or another. If it’s already loaded, the ‘Completed’ line should fine immediately. You’re not really gaining anything by doing it again.

Up to you though.

1 Like

I see, thank you! I’ll just goahead and leave everything on my async load completed event and not bother trying to bypass it.