I have a blueprint that has an editor-only component that creates a CustomizableObject instance at editor time in order to display a character with given data. It assigns this a UCustomizableSkeletalComponent, that it will also create if it doesn’t exist.
I assign data to an instance of the blueprint in scene, which I know causes the creation of a new CustomizableObjectInstance.
Sometime after this, I open up the blueprint and hit compile. I get the crash at this time.
It happens in this code:
for (TObjectIterator<UCustomizableObjectInstanceUsage> Usage; Usage; ++Usage)
{
UCustomizableObjectInstanceUsagePrivate* UsagePrivate = Usage->GetPrivate();
if (!UsagePrivate->bPendingSetSkeletalMesh)
Often, this happens because another component that CustomizableSkeletalComponent needs isn’t initialized in time for the customizable object to gather the data.
We did make a change to how PrivateUsage was access here:
But there are still cases where that will not matter due to component initialization, and depending on how you’re implementing these components.
I have a blueprint that has an editor-only component that creates a CustomizableObject instance at editor time in order to display a character with given data. It assigns this a UCustomizableSkeletalComponent, that it will also create if it doesn’t exist.
Are you doing this through AddComponent? What does this flow look like?
That change does look like it would solve the problem.
The code looks like this:
CreatorComponent = Cast<UCreatorCustomizationComponent>(owner->GetComponentByClass(UCreatorCustomizationComponent::StaticClass()));
if (!IsValid(CreatorComponent))
{
// give it a creator customization component if it doesn't have one
CreatorComponent = NewObject<UCreatorCustomizationComponent>(owner);
CreatorComponent->RegisterComponent();
CreatorComponent->SetIsVisualizationComponent(true);
CreatorComponent->SetHiddenInGame(true);
CreatorComponent->bIsEditorOnly = true;
}
I found that if I just had the CreatorCustomizationComponent already on the mesh component in the blueprint, the error didn’t occur. So I have a workaround currently.
Got it, I’ll raise this to the team as an example for them, if they decide that this should be a bug I’ll log it and post it here for you to follow.
If you still need to dynamically generate the component, depending on the timing and whether this is a subclass of CustomizableSkeletalComponent, you might be able to set the Instance either from something likePostInitProperties in the component or by overriding PostInitializeComponents on your actor during actor instantiation.