• Runtimes
  • [UE4] Can't save object with references to Spine in it

Related Discussions
...

Hey everyone

I'm trying to make a tool that automatically creates the actor type I need and populates it with the spine atlas and skeleton data that is selected in the content browser. I have to do this over and over so making it faster would be really nice.

I set up an editor utility widget to run my script, which seems to work, but I can't save the object it creates:

I also get a crash if I try to open the object.

I guess I'll start pasting code in the hope that someone spots what the problem is.

I have SpinePlugin and SpineEditorPlugin in my module dependencies.

This is how I attach the spine components:

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Spine")
    USpineSkeletonDataAsset * SpineSkeleton;

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Spine")
    USpineAtlasAsset * SpineAtlas;
ASpineActor::ASpineActor(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
    PrimaryActorTick.bCanEverTick = true;
    SpineSkeletonRenderer = NewObject<USpineSkeletonRendererComponent>(this, FName(TEXT("SpineSkeletonRenderer")));
    SpineSkeletonAnimation = NewObject<USpineSkeletonAnimationComponent>(this, FName(TEXT("SpineSkeletonAnimation")));

SpineSkeletonAnimation->SkeletonData = SpineSkeleton;
SpineSkeletonAnimation->Atlas = SpineAtlas;
}

And this is the script I wrote to create and save the actor: https://pastebin.com/0nkkY0Bn

Hm, the code looks fine to me, especially the property definitions which should do the trick. How did you specify the dependency on the Spine plugin(s)?

My mistake, I needed to use UBlueprint to create a blueprint of my class instead of instantiating it and saving it, after which everything worked fine.

The other mistake was not to use CreateDefaultSubObject() in the constructor. I erroneously believed that like the Highlander there could be only one.

Once I sorted those out it's working perfectly, although I still need to work out how to save changes made programmatically to the CDO.

CreateDefaultSubObject() has had me bang my head a few walls as well... Glad you figured out most of the issue. I'm afraid my UE4 foo (and their docs) aren't quite up to snuff to give valuable advice here.

4일 후

No problem at all. I finished what I was doing and now I have a useful tool for creating spine actors from a bulk selection in the content browser. I'll post it here once I've cleaned it up a bit.

Awesome, thanks!