Download

Create an destory a UObject while in editor

I am creating an UObject while the game is in editor through the OnConstruction() and save it in a UPROPERTY() pointer in the same class that spawned it.

The problem is that when I try to save the map, I get the following error.


Can't save ../../../../Projects/Mythology/Content/ThirdPerson/Maps/ThirdPersonExampleMap.umap: Graph is linked to private object(s) in an external package.
External Object(s):
None
  
Try to find the chain of references to that object (may take some time)?

Then I get this error.


The asset '/Game/ThirdPerson/Maps/ThirdPersonExampleMap' (ThirdPersonExampleMap.umap) failed to save.

Cancel: Stop saving all assets and return to the editor.
Retry: Attempt to save the asset again.
Continue: Skip saving this asset only.

Anyway to auto delete the UObject so I don’t encounter this error?

Well if you mark the property UPROPERTY(Transient) I’d think that will probably avoid the error, since it shouldn’t attempt to save it. But presumably if you’re assigning it to a property, you want the object to be saved, no?

Can you show the code where you create the object? If you setup its outer to be the object on which the property exists, I would think it should work fine:


MyProperty = NewObject< UMyObject >(this);