TSoftClassPtr Not Loading

Inside of a UActorComponent…

I’ve got a UPROPERTY:

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) TSoftClassPtr<UMyObject> Initial;

And on BeginPlay() I’m trying to:

UClass* InitialClass = Initial.LoadSynchronous(); if (IsValid(InitialClass)) { } else { UE_LOG(LogTemp, Display, TEXT("FAILED TO LOAD INITIAL.")); }

That code ALWAYS fails on the first PlayInEditor…

And it ALWAYS succeeds for every PlayInEditor after the first.

Is there something that needs to be done to force it to load when you open the editor and press play?

Thanks!

I had a similar problem and i believe its because your assets are not finished leading by the time you BeginPlay(). You could try force loading early using LoadSynchronous().

Yeah, I thought that, too and I even have a LoadSynchronous() on the class in the code I posted. It’s only a code class extended by a blueprint. Does that matter?

have you tried using subclass, in terms of TSubclassOf instead of what you have TSoftClassPtr, since subclass holds direct reference? Otherwise if you have to use soft class, maybe force a synchronous load in OnRegister()