private static void FillInNulls(Material mat, ShaderProperties property) { if (mat.HasProperty(property.propertyName)) { if (mat.GetTexture(property.propertyName) == null) { mat.SetTexture(property.propertyName, defaultTexture); } } }
/// <summary> /// A special method that gives the reorderable list a way to draw the GUI for the objects contained within it /// </summary> /// <returns>The item drawer.</returns> /// <param name="position">Position.</param> /// <param name="itemValue">Item value.</param> private static ShaderProperties PropertyItemDrawer(Rect position, ShaderProperties itemValue) { if (itemValue != null) { float originalHeight = position.height; float originalYPosition = position.y; position.height *= 0.5f; itemValue.markAsNormal = EditorGUI.Toggle(position, new GUIContent("Is Normal", "One thing to keep in mind is that textures cannot be set as a Unity normal map at run time currently, so if you are going to set this to true, make sure that you have a shader that can handle external normal maps. All this does is make sure that the texture is in the right format for these non native shaders"), itemValue.markAsNormal); position.y += position.height; itemValue.propertyName = EditorGUI.TextField(position, new GUIContent("Name", "This is the name of the property in the shader that you are references, as an example, the default property for diffuse shaders is _MainTex"), itemValue.propertyName); position.height = originalHeight; position.y = originalYPosition; position.width -= 50; position.x = position.xMax + 5; position.width = 45; } return itemValue; }
/// <summary> /// A special method that gives the reorderable list a way to draw the GUI for the objects contained within it /// </summary> /// <returns>The item drawer.</returns> /// <param name="position">Position.</param> /// <param name="itemValue">Item value.</param> static private ShaderProperties PropertyItemDrawer(Rect position, ShaderProperties itemValue) { if (itemValue != null) { float originalHeight = position.height; float originalYPosition = position.y; position.height *= 0.5f; itemValue.markAsNormal = EditorGUI.Toggle(position, new GUIContent("Is Normal", "One thing to keep in mind is that textures cannot be set as a Unity normal map at run time currently, so if you are going to set this to true, make sure that you have a shader that can handle external normal maps. All this does is make sure that the texture is in the right format for these non native shaders"), itemValue.markAsNormal); position.y += position.height; itemValue.propertyName = EditorGUI.TextField(position, new GUIContent("Name", "This is the name of the property in the shader that you are references, as an example, the default property for diffuse shaders is _MainTex"), itemValue.propertyName); position.height = originalHeight; position.y = originalYPosition; position.width -= 50; position.x = position.xMax + 5; position.width = 45; } return(itemValue); }