advanced example
This commit is contained in:
1 parent
8c0a639fba
commit
6fe57915e8
99 files changed
+1329
-56
No files matched your search
@@ -6,7 +6,20 @@ import unreal
|
||||
from .paths import GENERATED, PROJECT, slug
|
||||
|
||||
|
||||
def import_model(filename, name="Character"):
|
||||
def _existing_model(name):
|
||||
destination = f"{GENERATED}/Imports/{slug(name)}"
|
||||
if not unreal.EditorAssetLibrary.does_directory_exist(destination):
|
||||
return None
|
||||
meshes = [unreal.load_asset(path) for path in unreal.EditorAssetLibrary.list_assets(destination, recursive=True)]
|
||||
meshes = [obj for obj in meshes if isinstance(obj, unreal.StaticMesh)]
|
||||
return meshes[0] if len(meshes) == 1 else None
|
||||
|
||||
|
||||
def import_model(filename, name="Character", reimport=True):
|
||||
if not reimport:
|
||||
mesh = _existing_model(name)
|
||||
if mesh is not None:
|
||||
return mesh
|
||||
source = Path(filename).expanduser()
|
||||
source = (source if source.is_absolute() else PROJECT / source).resolve()
|
||||
if not source.is_file():
|
||||
|
||||
Reference in new issue
Block a user