public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); EditorGUILayout.Space(); editor.RenderModeSelector(); editor.PropertySelector(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); GUILayout.Box(GUIContent.none, ObiEditorUtils.GetSeparatorLineStyle()); EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); import = EditorGUILayout.Foldout(import, "Import texture"); if (import) { propertyTexture = (Texture2D)EditorGUILayout.ObjectField("Source", propertyTexture, typeof(Texture2D), false); floatProperty = editor.currentProperty as ObiBlueprintFloatProperty; colorProperty = editor.currentProperty as ObiBlueprintColorProperty; if (floatProperty != null) { textureReadCallback = FloatFromTexture; textureChannel = (TextureChannel)EditorGUILayout.EnumPopup("Source channel", textureChannel); minPropertyValue = EditorGUILayout.FloatField("Min value", minPropertyValue); maxPropertyValue = EditorGUILayout.FloatField("Max value", maxPropertyValue); } else if (colorProperty != null) { textureReadCallback = ColorFromTexture; } if (GUILayout.Button("Import")) { Undo.RecordObject(editor.blueprint, "Import particle property"); if (!meshBasedEditor.ReadParticlePropertyFromTexture(propertyTexture, textureReadCallback)) { EditorUtility.DisplayDialog("Invalid texture", "The texture is either null or not readable.", "Ok"); } // force automatic range calculation for floating point properties. if (floatProperty != null) { floatProperty.autoRange = true; } editor.Refresh(); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); GUILayout.Box(GUIContent.none, ObiEditorUtils.GetSeparatorLineStyle()); EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); export = EditorGUILayout.Foldout(export, "Export texture"); if (export) { exportWidth = EditorGUILayout.IntField("Texture width", exportWidth); exportHeight = EditorGUILayout.IntField("Texture height", exportHeight); padding = EditorGUILayout.IntField("Padding", padding); if (GUILayout.Button("Export")) { var path = EditorUtility.SaveFilePanel("Save texture as PNG", "", "property.png", "png"); if (path.Length > 0) { // force automatic range calculation for floating point properties. if (floatProperty != null) { floatProperty.autoRange = true; } editor.Refresh(); if (!meshBasedEditor.WriteParticlePropertyToTexture(path, exportWidth, exportHeight, padding)) { EditorUtility.DisplayDialog("Invalid path", "Could not write a texture to that location.", "Ok"); } } } } EditorGUILayout.EndVertical(); }
public ObiFloatAddBrushMode(ObiBlueprintFloatProperty property) : base(property) { }