MeshSettings ​
Inherits: Resource
The settings of the meshes of the mesh database that cannot be kept in the mesh file itself: the offsets and points of a weapon, the skeleton types a mesh fits, the materials it accepts, its skin. A mesh made as a Godot resource (.tres or .res) keeps these as metadata inside its own file. A mesh that Godot imports from another format (.obj, .glb, .gltf, .fbx, .blend) cannot be saved (the engine rewrites the import and has no way to write into the source), so its settings are kept here, in res://src/data/meshes/mesh_settings.tres, under the UID of the mesh file. Godot gives every imported file a UID in its .import file, and the UID follows the file when it is moved or renamed in the editor. MeshSource.load_mesh puts the settings back on the mesh when it loads it, so the rest of the toolkit reads them as metadata, whichever way they are kept.
Properties ​
Dictionary | entries | {} |
Methods ​
MeshSettings | get_instance() static |
void | reset() static |
bool | is_resource_format( path: String ) static |
String | key_of( path: String ) static |
Dictionary | get_settings( path: String ) |
void | set_settings( path: String, settings: Dictionary, save: bool = true ) |
void | apply_to( mesh: Mesh, path: String ) |
Error | save_mesh( mesh: Mesh, path: String ) static |
Dictionary | orphans() |
Constants ​
StringPATH ="res://src/data/meshes/mesh_settings.tres"- The file that holds the settings.PackedStringArrayRESOURCE_FORMATS =["tres", "res"]- The file types that can hold their own metadata.
Property descriptions ​
Dictionary entries = ​
The settings of each mesh file: UID (or "path:<path>" for a file with no UID) -> { "path": the last known path, setting name -> value }
Method descriptions ​
MeshSettings get_instance() ​
The settings of the project (empty when it has none yet).
void reset() ​
Forgets what was read (the tests, and the editor after the file changed).
bool is_resource_format( path: String ) ​
Is this mesh file a Godot resource that keeps its own metadata?
String key_of( path: String ) ​
The key of a mesh file: its UID as text, or "path:<path>" when the file has none.
Dictionary get_settings( path: String ) ​
The settings kept for a mesh file (a copy; empty when it has none).
void set_settings( path: String, settings: Dictionary, save: bool = true ) ​
Replaces the settings of a mesh file and writes the settings file. An empty dictionary removes the entry.
void apply_to( mesh: Mesh, path: String ) ​
Puts the stored settings on a mesh as metadata (what MeshSource does when it loads the mesh). Settings the mesh has already are kept.
Error save_mesh( mesh: Mesh, path: String ) ​
Saves the metadata a mesh has now: into the mesh file for a resource format, into the settings file for any other. This is the one call the mesh editor makes after it changes a setting. Returns OK or the error.
Dictionary orphans() ​
The entries whose mesh file is gone (for the validation of the mesh database): UID or path -> last known path.