INNER CODE UNIT · Python
_import_image_to_library
skarndev/umodel_tools · umodel_tools/asset_importer.py:132
def _import_image_to_library(self,
tex_path: str,
tex_lib_path: str,
tex_umodel_path: str,
db: asset_db.AssetDB):
"""Import image texture to asset library from UModel output.
:param tex_path: Path to texture in game format.````
:param tex_lib_path: Path to texture in the library dir (absolute).
:param tex_umodel_path: Path to texture in the UModel output dir (absolute).
"""
# copy file to library dir
os.makedirs(os.path.dirname(tex_lib_path), exist_ok=True)
shutil.copyfile(tex_umodel_path, tex_lib_path)
img = bpy.data.images.load(filepath=tex_lib_path)
img.asset_mark()
img.asset_data.catalog_id = db.uid_for_entry(os.path.dirname(tex_path))