FindObject only works after explicitly opening an asset

I am using the following code to try and load all kinds of assets including blueprints and it seems that some of the time i need to open that asset to cause the code to work.

I’m not 100% sure if this is a bug because I would imagine this sort of thing must have been found, so if it is not and i am doing something wrong i apologise.

if anyone needs help reproducing it all you need to do is attempt to use FindObject. this happens on various projects and the first time i can recall it happening was on 4.9 or 4.10

Hey -

Are you loading the objects into memory first? If the object is not loaded then FindObject() will fail. In that case you would need to use LoadObject instead. You can find more information on FindObject and LoadObject here:

Cheers

When I first encountered this problem, I did try comparing find and load object each with various parameter combinations, but I found that loadobject never worked for me. Is load object the correct way to do this then?

They are both used based on if the object is loaded or not. If the object has already been loaded or created, then you can use FindObject(). If the object has not been loaded and still needs to be, then LoadObject() is the correct call to use. Based on your screenshot I don’t see where it is being loaded so you may want to try using LoadObject instead.

Would i be able to just replace all my FindObject calls with LoadObject? or will that cause problems if the asset is already loaded?

Also, if it does cause problems, how would i check whether or not an object has been loaded?

LoadObject does the equivalent of FindObject as well as load it. To answer your question, you should be able to LoadObject even if the object has been loaded previously, however this may give you a warning.