Unity-Technologies/UnityCsReference · error · ArgumentException
The MaterialProperty '{0}' should be of type 'Texture' (its
Error message
The MaterialProperty '{0}' should be of type 'Texture' (its type is '{1})' What it means
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).
Source
Thrown at Editor/Mono/Inspector/MaterialEditor.cs:1660
EditorGUI.BeginChangeCheck();
// Mixed value mask is 4 bits for the uv offset & scale (First bit is for the texture itself)
int mixedValuemask = property.mixedValueMask >> 1;
Vector4 scaleAndOffset = TextureScaleOffsetProperty(position, property.textureScaleAndOffset, mixedValuemask, partOfTexturePropertyControl);
if (EditorGUI.EndChangeCheck())
property.textureScaleAndOffset = scaleAndOffset;
EndProperty();
EndAnimatedCheck();
return 2 * kLineHeight;
}
private Texture TexturePropertyBody(Rect position, MaterialProperty prop)
{
if (prop.propertyType != ShaderPropertyType.Texture)
{
throw new ArgumentException(string.Format("The MaterialProperty '{0}' should be of type 'Texture' (its type is '{1})'", prop.name, prop.propertyType));
}
m_DesiredTexdim = prop.textureDimension;
System.Type t = MaterialEditor.GetTextureTypeFromDimension(m_DesiredTexdim);
// Why are we disabling the GUI in Animation Mode here?
// If it's because object references can't be changed, shouldn't it be done in ObjectField instead?
bool wasEnabled = GUI.enabled;
EditorGUI.BeginChangeCheck();
if ((prop.propertyFlags & ShaderPropertyFlags.NonModifiableTextureData) != 0)
GUI.enabled = false;
EditorGUI.showMixedValue = prop.hasMixedValue;
int controlID = GUIUtility.GetControlID(12354, FocusType.Keyboard, position);
var newValue = EditorGUI.DoObjectField(position, position, controlID, prop.textureValue, target, t, TextureValidator, false) as Texture;
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
editor.TextureProperty(rect, FindProperty("_Tint", props), "Tint"); // _Tint is a Color
// after
var tintProp = FindProperty("_Tint", props);
if (tintProp.propertyType == ShaderPropertyType.Texture)
editor.TextureProperty(rect, tintProp, "Tint");
else
editor.ColorProperty(rect, tintProp, "Tint"); Defensive patterns
Strategy: type-guard
Validate before calling
bool IsTextureProperty(MaterialProperty p) => p != null && p.propertyType == ShaderPropertyType.Texture;
Type guard
static bool IsTextureSlot(MaterialProperty p) => p.propertyType == ShaderPropertyType.Texture;
Try / catch
try { editor.TextureProperty(rect, prop); }
catch (ArgumentException ex) { Debug.LogWarning(ex.Message); } Prevention
- Check propertyType before each typed drawer.
- Keep shader property names and types in sync with the ShaderGUI.
- Validate FindProperty results against expected types.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The SerializedProperty '{0}' is not supported by BeginProper
- List of materials contains null
- Given rpAssetType must derive from RenderPipelineAsset
- Could not find MaterialProperty: '{propertyName}', Num prope
- No material targets provided
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/6d51c90a4f83a0f1.
Report an issue: GitHub.