# \[UE4\] Can't save object with references to Spine in it  Search this topic… Post a reply

**URL:** <https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [October 1, 2019, 12:31am UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690 "2019-10-01T00:31:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antidamage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/antidamage/32/918692_2.png) [@Antidamage](https://forums.unrealengine.com/u/Antidamage)\
**Post date:** [October 1, 2019, 12:31am UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/1 "2019-10-01T00:31:21Z")

</div>

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:

[![](https://i.imgur.com/UrsLRkX.png) ](https://i.imgur.com/UrsLRkX.png)

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:

```auto

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

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Spine")
    USpineAtlasAsset * SpineAtlas;

```

```auto

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: [ASpineActor \* UPAndBEditorUtilityWidget::CreateSpineBlueprint(){ // Assign s - Pastebin.com](https://pastebin.com/0nkkY0Bn)

---

<div class="post-metadata">

**Author:** ![Antidamage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/antidamage/32/918692_2.png) [@Antidamage](https://forums.unrealengine.com/u/Antidamage)\
**Post date:** [October 1, 2019, 10:06am UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/2 "2019-10-01T10:06:38Z")

</div>

I’ve made a bit of progress and now the asset is created, the right stuff is populated and it can be saved without the warning.

Unfortunately the asset still throws an assertion on opening, which without the debugger is fatal:

AssetSelection.cpp (133):

```auto

if ( !ActorInfo.SharedWorld )
{
    ActorInfo.SharedWorld = CurrentActor->GetWorld();
    check(ActorInfo.SharedWorld);
}

```

CurrentActor is definitely valid, but I can’t inspect ActorInfo for whatever reason. It seems reasonable to assume that there is no current world. Keep in mind that this is a blueprint in the content browser being opened.

Any idea what’s probably causing it?

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [October 1, 2019, 12:29pm UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/3 "2019-10-01T12:29:10Z")

</div>

Content browsers don’t initialize any world context.  
Only when you open an editor tool with a viewport or play in editor then a pointer to a world is set, unless you override the GetWorld() function an asset will always return nullptr while instances should return the world they are spawned in.

---

<div class="post-metadata">

**Author:** ![Antidamage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/antidamage/32/918692_2.png) [@Antidamage](https://forums.unrealengine.com/u/Antidamage)\
**Post date:** [October 1, 2019, 12:43pm UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/4 "2019-10-01T12:43:55Z")

</div>

I realised my mistake and switched to a UBlueprint and CreateBlueprint(), which is giving me what I wanted.

The next step I believe is to load the CDO and make the changes I want to make programmatically. However what I’ve tried isn’t making any changes:

```auto

ASpineActor * CDO = ASpineActor::StaticClass()->GetDefaultObject<ASpineActor>();
    CDO->SpineSkeletonAnimation->SkeletonData = SpineSkeleton;
    CDO->SpineSkeletonAnimation->Atlas = SpineAtlas;
    CDO->SaveConfig();
    Blueprint->ReloadConfig();

```

Any suggestions? I know you’re the king of UBlueprints Bruno. 😃

Edit: and what happens if I use GetDefaultSubobjectByName(FName(“SpineSkeletonAnimation”) instead? Will it change that component’s defaults for every single blueprint instance that uses it, or just the one attached to this blueprint?

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [October 1, 2019, 1:31pm UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/5 "2019-10-01T13:31:17Z")

</div>

In Property Transfer plugin there’s these functions I wrote for this:

```auto

template<typename T>
T* GetBlueprintCDO(UBlueprint* Blueprint) {

    if (Blueprint == nullptr) {return nullptr;}

    const UClass* BlueprintClass = Blueprint->GeneratedClass;

    return Cast<T>(BlueprintClass->ClassDefaultObject);

}

```

```auto

UBlueprint* FPropertyTransferManager::GetBlueprintFromOBJ(UObject* OBJ) {

    UBlueprint* BP = nullptr;

    if (OBJ)
    {
        BP = Cast<UBlueprint>(OBJ);

        if (BP == nullptr) {
            BP = Cast<UBlueprint>(OBJ->GetClass()->ClassGeneratedBy);
        }
    }

    return BP;
}

```

---

<div class="post-metadata">

**Author:** ![Antidamage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/antidamage/32/918692_2.png) [@Antidamage](https://forums.unrealengine.com/u/Antidamage)\
**Post date:** [October 1, 2019, 1:43pm UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/6 "2019-10-01T13:43:21Z")

</div>

That’s handy, let me give it a go. Cheers!

Edit: that worked. You are amazing Bruno. That should be in the engine.

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [October 1, 2019, 1:49pm UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/7 "2019-10-01T13:49:03Z")

</div>

Btw you usually have to call _-\>Modify()_ on the CDO before you make changes to a UBlueprint\* asset…  
Or use helper methods such as:

```auto

FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(myBlueprint);

```

---

<div class="post-metadata">

**Author:** ![Antidamage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/antidamage/32/918692_2.png) [@Antidamage](https://forums.unrealengine.com/u/Antidamage)\
**Post date:** [October 1, 2019, 1:59pm UTC](https://forums.unrealengine.com/t/ue4-cant-save-object-with-references-to-spine-in-it-search-this-topic-post-a-reply/131690/8 "2019-10-01T13:59:10Z")

</div>

Ah yeah, thank you. The SaveConfig() and Reload() was working but that seems better.
