Make copy of all materials into surface override at once

4.4

When you import a mesh, and you want to edit the material, so you copy it into the surface material override and make it unique, but some meshes have a ton of materials, like hundreds, can it all be done at once?

presumably each material is one of a hundred because they are different materials from one-another so they cannot be done all at once because they are different materials. If you want to assign the same material to multiple surface material override slots then you can save the material as a resource and load it for applicable slots.

nah i just want to copy each material to its respective surface override to edit it. Your right and thats what ive been doing but it lowk takes to long

If you want one material for the entire mesh you can provide a single material override under the “Geometry” section. Otherwise you can drag a previously set material onto a new slot to copy it, just a few pixels away.

Do it with an import script.

@tool
extends EditorScenePostImport

const TEXTURE = preload("res://path/texture.png")
var new_material: StandardMaterial3D

func _post_import(scene):
	new_material = StandardMaterial3D.new()
	new_material.albedo_texture = TEXTURE
	iterate(scene)
	return scene

func iterate(node):
	if node is MeshInstance3D:
		node.material_override = new_material
	# Recursively call this function on any child nodes that exist.
	for child in node.get_children():
		iterate(child)

If you’ve already saved the material as a file then you can use:

@tool
extends EditorScenePostImport

const NEW_MATERIAL = preload("res://path/material.tres")

func _post_import(scene):
	iterate(scene)
	return scene

func iterate(node):
	if node is MeshInstance3D:
		node.material_override = NEW_MATERIAL
	# Recursively call this function on any child nodes that exist.
	for child in node.get_children():
		iterate(child)
1 Like