private Texture TexturePropertyBody(Rect position, MaterialProperty prop)
{
System.Type type;
if (prop.type != MaterialProperty.PropType.Texture)
{
throw new ArgumentException(string.Format("The MaterialProperty '{0}' should be of type 'Texture' (its type is '{1})'", prop.name, prop.type));
}
this.m_DesiredTexdim = prop.textureDimension;
switch (this.m_DesiredTexdim)
{
case MaterialProperty.TexDim.Tex2D:
type = typeof(Texture);
break;
case MaterialProperty.TexDim.Tex3D:
type = typeof(Texture3D);
break;
case MaterialProperty.TexDim.Cube:
type = typeof(Cubemap);
break;
case MaterialProperty.TexDim.Any:
type = typeof(Texture);
break;
default:
type = null;
break;
}
bool enabled = GUI.enabled;
EditorGUI.BeginChangeCheck();
if ((prop.flags & MaterialProperty.PropFlags.PerRendererData) != MaterialProperty.PropFlags.None)
{
GUI.enabled = false;
}
EditorGUI.showMixedValue = prop.hasMixedValue;
int id = GUIUtility.GetControlID(0x3042, EditorGUIUtility.native, position);
Texture texture = EditorGUI.DoObjectField(position, position, id, prop.textureValue, type, null, new EditorGUI.ObjectFieldValidator(this.TextureValidator), false) as Texture;
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
{
prop.textureValue = texture;
}
GUI.enabled = enabled;
return prop.textureValue;
}