use TSoftObjectPtr return NULL

i use TSoftObjectPtr , but always return Null , why?

If you want to use a Soft Object, you need to load it. There’s a LoadSynchronous() method but I’ve found it doesn’t work with levels. If you want to use it with levels, use these methods:

UGameplayStatics::LoadStreamLevelBySoftObjectPtr()

This actually creates a streaming level, not a UWorld pointer. So for unloading (or getting a pointer to the loaded level), I’ve only been able to do it with this->GetWorld()->GetStreamingLevels(); and then find the level you want to unload and then grabbing the name from it, but UGameplayStatics::UnloadStreamLevel() wants the name in a different format. There’s likely an easier way to unlead a level directly on UStreamingLevel, but I couldn’t find it.

edit: Oh, you seem to have a callback when the level is finished loading. I think it’s null because for some reason, a level is a UStreamingLevel. So you’ll likely have to scan GetStreamingLevels() and find the one with the same path. (and make sure to use UStreamingLevel::IsLevelLoaded() since it will return all levels including unloaded levels)

Thanks for your reply , but i use blueprint LoadAsycAsset loaded the level first ,like this

and now i fixed it , you should use IsNull() function to judge the null pointer ,

because i find the soft pointer is like this, i guess it’s a asyc load so weakptr is nullptr , is that right?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.