{"record":{"id":"e30790a8e2e29587","repo":"FyroxEngine/Fyrox","slug":"there-s-already-a-material-resource-binding-with","errorCode":null,"errorMessage":"There's already a material resource binding with {name}!","messagePattern":"There's already a material resource binding with (.+?)!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-material/src/lib.rs","lineNumber":923,"sourceCode":"    }\n\n    /// Tries to find a property group with the given name, creates a new group with the given name\n    /// if there's no such group.\n    pub fn try_get_or_insert_property_group(\n        &mut self,\n        name: impl Into<ImmutableString>,\n    ) -> &mut MaterialPropertyGroup {\n        let name = name.into();\n        if let MaterialResourceBinding::PropertyGroup(group) = self\n            .resource_bindings\n            .entry(name.clone())\n            .or_insert_with(|| {\n                MaterialResourceBinding::PropertyGroup(MaterialPropertyGroup::default())\n            })\n        {\n            group\n        } else {\n            panic!(\"There's already a material resource binding with {name}!\");\n        }\n    }\n\n    /// Sets new value of the resource binding with given name.\n    ///\n    /// # Type checking\n    ///\n    /// A new value must have the same type as in shader, otherwise an error will be generated at\n    /// attempt to render something with this material.\n    ///\n    /// # Example\n    ///\n    /// ```no_run\n    /// # use fyrox_material::{Material, MaterialProperty};\n    /// # use fyrox_core::color::Color;\n    /// # use fyrox_core::sstorage::ImmutableString;\n    ///\n    /// let mut material = Material::standard();","sourceCodeStart":905,"sourceCodeEnd":941,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-material/src/lib.rs#L905-L941","documentation":"Material::try_get_or_insert_property_group inserts a new MaterialPropertyGroup under the given name if none exists, but panics when a resource binding with that name already exists and is NOT a property group (e.g. it is a texture/sampler binding). The message includes the conflicting name. set_property is a typical caller: it calls this when the property group backing a property does not exist yet.","triggerScenarios":"Calling material.set_property(name, ...) or try_get_or_insert_property_group(name) where `name` collides with an existing non-property-group MaterialResourceBinding, such as a texture already bound under the same name.","commonSituations":"Defining a shader with a uniform whose name equals a texture binding name; copying property names between materials where one material uses the name for a texture; typos causing you to target a texture binding as a group.","solutions":["Rename one of the two bindings so the property group name is unique within the material.","Check the existing binding kind first (material.resource_bindings / binding_name) before calling.","If you intended to set a property inside an existing group, use the group's full name path rather than the texture binding name."],"exampleFix":"// before\nmaterial.set_property(\"diffuseTexture\", value); // name is already a texture binding\n// after\nmaterial.bind(\"diffuseTexture\", texture_resource); // set the texture instead of a property\nmaterial.set_property(\"material.color\", value);","handlingStrategy":"validation","validationCode":"if material.resource_bindings().contains_key(name) {\n    log_error(format!(\"binding {name} already exists\"));\n} else {\n    material.try_get_or_insert_property_group(name);\n}","typeGuard":null,"tryCatchPattern":"// Panics are not recoverable in normal Rust; guard by checking existing bindings first, or use catch_unwind for batch asset processing.","preventionTips":["Never reuse a texture binding name for a property group in a material.","Generate property names from the shader reflector so they cannot collide with texture slots.","Search materials for duplicate binding names during asset import."],"tags":["panic","material","name-conflict","property-group"],"backgroundTag":"file-already-exists","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}