// Called after update is done. public void Reset() { forceDirty = false; preset = colormap.preset; colormapPrecision = colormap.colormapPrecision; numberOfColors = colormap.numberOfColors; }
public Colormap() { preset = PalettePresets.PresetName.Classic1; palette = new Color[256]; numberOfColors = 16; usedColors = new bool[256]; colormapPrecision = ColormapPrecision.Medium; initialized = false; PalettePresets.SetPalette(preset, this); }
void Reset() { horizontalResolution = 320; verticalResolution = 200; palette = new Color[256]; numberOfColors = 16; usedColors = new bool[256]; colormapPrecision = ColorMapPrecision.Medium; preset = PalettePresets.PresetName.Classic1; strength = 1; autoUpdateColormap = true; ApplyPreset(); UpdateColormap(); }
void DrawStaticProperties() { EditorGUILayout.LabelField("STATIC PROPERTIES", EditorStyles.boldLabel); ++EditorGUI.indentLevel; PalettePresets.PresetName oldPalettePreset = _target.preset; PalettePresets.PresetName newPalettePreset = (PalettePresets.PresetName)EditorGUILayout.EnumPopup("Palette Preset", _target.preset); preset.enumValueIndex = (int)newPalettePreset; if (newPalettePreset != oldPalettePreset) { serializedObject.ApplyModifiedProperties(); _target.ApplyPreset(); serializedObject.Update(); colormapNeedsUpdating = true; } int oldNumberOfColors = numberOfColors.intValue; numberOfColors.intValue = EditorGUILayout.IntField("Number Of Colors", numberOfColors.intValue); if (numberOfColors.intValue != oldNumberOfColors) { colormapNeedsUpdating = true; if (numberOfColors.intValue < oldNumberOfColors) { preset.enumValueIndex = (int)PalettePresets.PresetName.Custom; } } int oldPrecision = colormapPrecision.enumValueIndex; colormapPrecision.enumValueIndex = (int)(ColorMapPrecision)EditorGUILayout.EnumPopup("Colormap Precision", _target.colormapPrecision); if (oldPrecision != colormapPrecision.enumValueIndex) { colormapNeedsUpdating = true; } autoUpdateColormap.boolValue = EditorGUILayout.Toggle("Auto Update Colormap", autoUpdateColormap.boolValue); --EditorGUI.indentLevel; EditorGUI.BeginDisabledGroup(autoUpdateColormap.boolValue); if (!_target.isUpdatingColormap) { if (GUILayout.Button("Update Colormap", GUILayout.Width(130), GUILayout.Height(20))) { UpdateColormap(); } } EditorGUI.EndDisabledGroup(); if (_target.isUpdatingColormap) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel", GUILayout.Width(130), GUILayout.Height(20))) { _target.CancelColormapUpdate(); } Rect progressRect = GUILayoutUtility.GetRect(0, 26, GUILayout.ExpandWidth(true)); EditorGUI.ProgressBar(progressRect, _target.GetProgress(), "Updating Colormap"); EditorUtility.SetDirty(target); EditorGUILayout.EndHorizontal(); } DrawColors(); EditorGUILayout.Space(); }