I’m doing something a bit more unusual for our team, I’m making a digital asset management system, which stores different asset types.
One of the types I’m storing is .uassets.
I’ve got a QT app which has paths to various .uasset files and when the user downloads, these files are integrated into the unreal project via shutil commands (copytree, copyfile etc) & then scanned with the asset registry using the UE python api.
I am hitting some interesting blocks however.
If I have an asset open, and try to copy over it -> permission denied.
If I delete, then copy an asset, -> references are broken.
I understand this isn’t using the standard import approach, but I’m wondering if there is are any available method for achieving this (without stepping into C++)?
The most important information that you need to know if that the assets references stored in uasset files have the following form: /Game/<SubPath>/AssetName.AssetName. “/Game” represents the Content folder of your project. Assets that come from a plugin with use the /PluginName prefix as a proxy for the plugin’s Content folder. So when moving UAsset files between projects, it is imperative that the same folder hierarchy is present in the target projects or the references will break.
Regarding the problems you are facing, it would be interesting to get more details on the circumstance.
Overwriting an open asset: The editor should not be locking uasset files so you should be able to overwrite them while the editor is running. Are you sure the copy isn’t blocked by a virus\malware scanner?
Delete then copy: That should not have anything to do with references if the dependencies are present in the same location than in the original project.
This worked for me, added some comments for clarity:
def transfer\_content(self, src, dst):
packages \= self.get\_transfer\_packages(src, dst) \# This just gets me a list of the packages that already exist, so I can save them.
self.load\_save\_utils.save\_packages(packages, False) \# Save the packages
if os.path.exists(src):
shutil.copytree(src, dst,
dirs\_exist\_ok\=True)
self.load\_save\_utils.reload\_packages(packages) \# reload the packages to update the content