diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 28af3d32205..4906ceb2eb8 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -102,6 +102,9 @@ void PrimitiveMesh::_request_update() { } int PrimitiveMesh::get_surface_count() const { + if (pending_request) { + _update(); + } return 1; } diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 654994b83fb..33fa8d365fc 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -601,8 +601,9 @@ void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surf Instance *instance = instance_owner.get(p_instance); ERR_FAIL_COND(!instance); - if (instance->update_item.in_list()) { - _update_dirty_instance(instance); + if (instance->base_type == VS::INSTANCE_MESH) { + //may not have been updated yet + instance->materials.resize(VSG::storage->mesh_get_surface_count(instance->base)); } ERR_FAIL_INDEX(p_surface, instance->materials.size());