Godot Version
Godot 4.2
Question
I’m trying to add two testing blocks to the MeshLibrary: a dirt block and a stone block. Both blocks have two shapes: a full block and a slab. The information is contained in a dictionary (blockDirectory) of dictionaries (block properties). The issue is that when I test this in-game, the dirt block has the stone texture. Interestingly, the print statement does show that the correct texture file is being used. And when I only had one shape per block (and was only using one for loop), there were no issues.
These are the results from the print statements:
dirt_full
res://textures/dirt.png
dirt_slab
res://textures/dirt.png
stone_full
res://textures/stone.png
stone_slab
res://textures/stone.png
for block in blockDirectory:
for shape in blockDirectory[block]["Shapes"]:
# Create a new item in the MeshLibrary.
var newID = mesh_library.get_last_unused_item_id()
mesh_library.create_item(newID)
# Give the new item a name.
mesh_library.set_item_name(newID, block + "_" + shape)
print(block + "_" + shape)
# Load mesh and apply a texture to it.
var newMesh = load(meshesPath + shape + meshExtension)
var newTexture = StandardMaterial3D.new()
newTexture.albedo_texture = load(texturesPath + blockDirectory[block]["Texture"] + textureExtension)
print(texturesPath + blockDirectory[block]["Texture"] + textureExtension)
newTexture.texture_filter = BaseMaterial3D.TEXTURE_FILTER_NEAREST
newMesh.surface_set_material(0, newTexture)
# Apply mesh to the new item.
mesh_library.set_item_mesh(newID, newMesh)