public static void NormalTextureField(GUIContent content, string property, TextureFieldType size = TextureFieldType.Small) { NormalTextureField(content, property, scopeMaterial, size); }
public static void NormalTextureField(GUIContent content, string property, Material material, TextureFieldType size = TextureFieldType.Small) { Texture2D normalTexture = (Texture2D)EditorGUILayout.ObjectField(content, material.GetTexture(property), typeof(Texture), false, GUILayout.Height((float)size)); if (normalTexture != null) { TextureImporter lImporter = (TextureImporter)TextureImporter.GetAtPath(AssetDatabase.GetAssetPath(normalTexture.GetInstanceID())); if (lImporter.textureType != TextureImporterType.NormalMap) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Texture is no normal map!"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Fix now")) { lImporter.textureType = TextureImporterType.NormalMap; lImporter.convertToNormalmap = true; } if (GUILayout.Button("To Settings")) { Selection.activeObject = lImporter; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } material.SetTexture(property, normalTexture); }
public static void TextureField(GUIContent content, string property, Material material, TextureFieldType size = TextureFieldType.Small) { Texture2D mainTexture = (Texture2D)EditorGUILayout.ObjectField(content, material.GetTexture(property), typeof(Texture2D), false, GUILayout.Height((float)size)); material.SetTexture(property, mainTexture); }