Transferring uasset files into a project using python

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++)?

Steps to Reproduce

Hello,

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.

Regards,

Martin

Hi Martin, thanks for replying.

The assets we are bringing in, we make sure to import into the exact same folder that we used before:

MyProject1 -> MyProject2

Game/MySpecialContent/MyNotSoPerfectBlueprintButHeyItWorks -> Game/MySpecialContent/MyNotSoPerfectBlueprintButHeyItWorks

We started exploring the delete then re-add option because we were getting blocked by this:

[Image Removed]However this was only occurring at the point of opening an asset in editor before reimporting.

I’m not sure about the virus / malware scanner, I can look into that our side.

I’ll continue to investigate the different behaviours and report back if I find anything.

Thank you :slight_smile:

I’ve just been testing this manually.

When try to copy the files within windows explorer, if the file has not been opened inside the unreal editor, it will copy.

If I do the same, but have the file opened, the process becomes blocked as it is “used by another program”.

If I save the asset prior to copying, I can copy the asset successfully (releasing the “lock”).

Then I reload the asset and it updates.

I’ll proceed to seeing if I can automate this!

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

Additional bit of information, it could have been any of the assets references that were open (one, or all) and this would prevent the overwriting.