Here is the context : I am currently working on a plugin to make some custom commands (in blueprints) to ease deployment or post builds processes (something that seems a little like the build xml file that make its apparition in UE 4.13).
Well, my issue is that I want to save/load some custom datas. I don't want theses datas to be saved in the Content directory, to hide them from the user and not pollute their project with asset that will not be packaged. So, I want to save these datas in Plugin/MyPlugin/Datas. My datas are stocked in a UObject*.
With that in mind, I thought custom asset was not I wanted since the factory (FactoryNew), perhaps, will force me to make my asset in the Content directory.
Here is the problem : So I am using CreatePackage/SavePackage/LoadPackage. But I am encountering some issues.
For datas creation, I do :
Then, to load the datas, I do :
This works. Until I add some datas in my object. I fill a TArray (as a UPROPERTY). Then I save it, but when I load it again. It crashes here :
LinkerLoad.cpp : line 3586
With 'Export.ObjectName = 0x00000017aeada028 "Default_Object"'. I do not know what is this Default_Object.
Any idea ? What I am doing wrong ? Should I use some custom asset to make a correct serialization ?
asked Oct 03 '16 at 08:47 PM in C++ Programming
Well, the dependency had no link with the real issue... I just misunderstood how the packaging system worked.
For anybody who is in my situation, here is the resolution.
The issue was concerning the paths between package, objects etc. In my situation, I wanted to create a package in a special path (not something like /Game, /Engine etc.). For the example, we will want to create our asset here : "MyProjectPath/Plugins/Datas/CustomAsset.uasset"
To start, we have to register a new mount point. You can do it in the initialization of your module.
Now, we create the package with CreatePackage by giving the name with the mount point (not absolute path). Does not require the ".uasset".
Afterwards, you can create the object and set it into the package like this :
NB : If you need to add some UObject* into MyDatas, you just have to do that, giving the package as outer :
Then, to save your package, you need the absolute path + .uasset extension :
Your object is saved ! Now, the loading. You have to use LoadPackage, using the path with the mount point (the one you used for CreatePackage).
Once your package is loaded, you have to search your object saved in it. For that, you have to use FindObject (with the name used during the NewObject) :
And that's all ! All your datas should be loaded correctly now.
answered Oct 05 '16 at 07:45 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here