Untitled
unknown
plain_text
11 days ago
1.0 kB
7
Indexable
@tool extends EditorScenePostImport # This sample changes all node names. var folderPath: String # Called right after the scene is imported and gets the root node. func _post_import(scene): folderPath = get_source_file().get_base_dir()+"/meshes" # Change all node names to "modified_[oldnodename]" iterate(scene) # Remember to return the imported scene return scene #Recursive function that is called on every node #(for demonstration purposes; EditorScenePostImport only requires a `_post_import(scene)` function). func iterate(node): if node != null: for child in node.get_children(): if child is MeshInstance3D: var meshResource: MeshInstance3D = child var targePath: String = folderPath + "/" + meshResource.name + ".res" if ResourceLoader.exists(targePath): ResourceSaver.save( meshResource.mesh,targePath ) meshResource.mesh.take_over_path(targePath) else: ResourceSaver.save( meshResource.mesh, targePath, ResourceSaver.FLAG_REPLACE_SUBRESOURCE_PATHS) iterate(child)
Editor is loading...
Leave a Comment