{"record":{"id":"6d51c90a4f83a0f1","repo":"Unity-Technologies/UnityCsReference","slug":"the-materialproperty-0-should-be-of-type-text","errorCode":null,"errorMessage":"The MaterialProperty '{0}' should be of type 'Texture' (its type is '{1})'","messagePattern":"The MaterialProperty '(.+?)' should be of type 'Texture' \\(its type is '(.+?)\\)'","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/MaterialEditor.cs","lineNumber":1660,"sourceCode":"            EditorGUI.BeginChangeCheck();\n            // Mixed value mask is 4 bits for the uv offset & scale (First bit is for the texture itself)\n            int mixedValuemask = property.mixedValueMask >> 1;\n            Vector4 scaleAndOffset = TextureScaleOffsetProperty(position, property.textureScaleAndOffset, mixedValuemask, partOfTexturePropertyControl);\n\n            if (EditorGUI.EndChangeCheck())\n                property.textureScaleAndOffset = scaleAndOffset;\n\n            EndProperty();\n\n            EndAnimatedCheck();\n            return 2 * kLineHeight;\n        }\n\n        private Texture TexturePropertyBody(Rect position, MaterialProperty prop)\n        {\n            if (prop.propertyType != ShaderPropertyType.Texture)\n            {\n                throw new ArgumentException(string.Format(\"The MaterialProperty '{0}' should be of type 'Texture' (its type is '{1})'\", prop.name, prop.propertyType));\n            }\n\n            m_DesiredTexdim = prop.textureDimension;\n            System.Type t = MaterialEditor.GetTextureTypeFromDimension(m_DesiredTexdim);\n\n            // Why are we disabling the GUI in Animation Mode here?\n            // If it's because object references can't be changed, shouldn't it be done in ObjectField instead?\n            bool wasEnabled = GUI.enabled;\n\n            EditorGUI.BeginChangeCheck();\n            if ((prop.propertyFlags & ShaderPropertyFlags.NonModifiableTextureData) != 0)\n                GUI.enabled = false;\n\n            EditorGUI.showMixedValue = prop.hasMixedValue;\n            int controlID = GUIUtility.GetControlID(12354, FocusType.Keyboard, position);\n            var newValue = EditorGUI.DoObjectField(position, position, controlID, prop.textureValue, target, t, TextureValidator, false) as Texture;\n            EditorGUI.showMixedValue = false;\n            if (EditorGUI.EndChangeCheck())","sourceCodeStart":1642,"sourceCodeEnd":1678,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/MaterialEditor.cs#L1642-L1678","documentation":"Thrown by TexturePropertyBody when a MaterialProperty passed to a texture drawer has propertyType != ShaderPropertyType.Texture. The method assumes it is drawing a texture slot and rejects any other shader property kind (Float, Vector, Color, Range).","triggerScenarios":"Calling TextureProperty / TexturePropertyMiniThumbnail with a MaterialProperty obtained by name where the shader declared that uniform as a non-texture type. Mismatch between shader property declaration and the GUI drawer assigned to it in a custom ShaderGUI.","commonSituations":"Shader renamed a property from sampler2D to float, but the ShaderGUI still calls TextureProperty. Copy-pasting a ShaderGUI between shaders whose property types differ. Referencing a property by the wrong name string.","solutions":["Verify the shader declares the property as a texture (sampler2D / Texture2D) and that FindProperty resolves the correct MaterialProperty.","Add a type check before calling TextureProperty: if (matProp.propertyType != ShaderPropertyType.Texture) skip or draw differently.","Correct the property name string passed to FindProperty to match the texture property."],"exampleFix":"// before\neditor.TextureProperty(rect, FindProperty(\"_Tint\", props), \"Tint\"); // _Tint is a Color\n\n// after\nvar tintProp = FindProperty(\"_Tint\", props);\nif (tintProp.propertyType == ShaderPropertyType.Texture)\n    editor.TextureProperty(rect, tintProp, \"Tint\");\nelse\n    editor.ColorProperty(rect, tintProp, \"Tint\");","handlingStrategy":"type-guard","validationCode":"bool IsTextureProperty(MaterialProperty p) => p != null && p.propertyType == ShaderPropertyType.Texture;","typeGuard":"static bool IsTextureSlot(MaterialProperty p) => p.propertyType == ShaderPropertyType.Texture;","tryCatchPattern":"try { editor.TextureProperty(rect, prop); }\ncatch (ArgumentException ex) { Debug.LogWarning(ex.Message); }","preventionTips":["Check propertyType before each typed drawer.","Keep shader property names and types in sync with the ShaderGUI.","Validate FindProperty results against expected types."],"tags":["unity","editor","material","shadergui","type-mismatch"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}