better basic example

This commit is contained in:
Vysyr committed 2026-11-01 00:07:02 +01:00
1 parent 1530b74d04
commit 934067f154
9 files changed
+129 -11

No files matched your search

+14 -1
View File
@@ -6,13 +6,25 @@ import unreal
from .paths import GENERATED, PROJECT, slug
def _disable_nanite(mesh):
# Workshop renders showed Nanite's coarse fallback mesh instead of the full model.
settings = mesh.get_editor_property("nanite_settings")
if settings.enabled:
settings.enabled = False
unreal.get_editor_subsystem(unreal.StaticMeshEditorSubsystem).set_nanite_settings(mesh, settings, True)
unreal.EditorAssetLibrary.save_loaded_asset(mesh)
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
if len(meshes) != 1:
return None
_disable_nanite(meshes[0])
return meshes[0]
def import_model(filename, name="Character", reimport=True):
@@ -80,6 +92,7 @@ def import_model(filename, name="Character", reimport=True):
raise RuntimeError(
f"Import {source.name}: oczekiwano jednego StaticMesh, otrzymano {len(meshes)}. "
"Plik musi zawierac statyczna geometrie modelu.")
_disable_nanite(meshes[0])
if source.suffix.lower() in {".glb", ".gltf"}:
# UE preserves material edits on mesh reimport. In this workflow Blender
# owns the look; explicitly synchronize the supported PBR parameters.