void OnDisable() { SavePaletteIfDirty(); StorePrefs(); Undo.undoRedoPerformed -= UndoRedoPerformed; _gui = null; _guiTexture = null; _guiColorFields = null; _guiEditMode = null; _guiHue = null; _guiSaturation = null; _guiLuminance = null; }
void OutputFormatChanged(GUIBase sender) { GUIEnumPopup popup = sender as GUIEnumPopup; EditorPrefs.SetInt(OutputFormatPrefsKey, (int)(OutputFormat)popup.value); }
private void RebuildGUI(Texture2D texture) { StorePrefs(); _gui = new GUIVertical(); GUIScrollView scroll = _gui.Add(new GUIScrollView()) as GUIScrollView; _guiTexture = scroll.Add(new GUITextureField(new GUIContent("Palette Texture"), PaletteTextureChanged, PaletteTextureWillChange)) as GUITextureField; _guiTexture.texture = texture; if (texture == null) { return; } if (IsTextureReadWrite(texture)) { _guiEditMode = scroll.Add(new GUIEnumPopup(new GUIContent("Edit Mode", "Palette edit operations affect either the single color or all colors in row/column/palette."), PaletteEditMode.Single)) as GUIEnumPopup; scroll.Add(new GUIIntSlider(new GUIContent("Shades", "Number of shades per color in palette"), texture.height, 2, 16, ShadeCountChanged)); _guiColorFields = new List <GUIColorField>(); // Adding 15 accounts for horizontal scrollbar if needed. // Need a non-hardcoded-hacky way of getting this info... float maxHeight = texture.height * 20.0f + 15.0f; GUIScrollView paletteScroll = scroll.Add(new GUIScrollView(GUILayout.MaxHeight(maxHeight))) as GUIScrollView; for (int y = texture.height - 1; y >= 0; y--) { GUIHorizontal horizontal = paletteScroll.Add(new GUIHorizontal()) as GUIHorizontal; for (int x = 0; x < texture.width; x++) { GUIColorField color = horizontal.Add(new GUIColorField(null, ColorChanged)) as GUIColorField; color.color = texture.GetPixel(x, y); color.tag = y * texture.width + x; color.controlName = PaletteControlName + color.tag; _guiColorFields.Add(color); } } scroll.Add(new GUISpace()); _guiHue = scroll.Add(new GUISlider(new GUIContent("Hue Offset", "Amount to offset hue when generating shades"), 0.0f, -1.0f, 1.0f)) as GUISlider; _guiSaturation = scroll.Add(new GUISlider(new GUIContent("Saturation Offset", "Amount to offset saturation when generating shades"), 0.0f, -1.0f, 1.0f)) as GUISlider; _guiLuminance = scroll.Add(new GUISlider(new GUIContent("Luminance Offset", "Amount to offset luminance when generating shades"), 0.0f, -1.0f, 1.0f)) as GUISlider; scroll.Add(new GUIButton(new GUIContent("Generate Shades", "Generate shades from root colors"), GenerateShadesClicked)); LoadPrefs(); } else { HandleTextureNotReadWrite(); } Repaint(); }
void RecordHotkeyChanged(GUIBase sender) { GUIEnumPopup popup = sender as GUIEnumPopup; EditorPrefs.SetInt(RecordHotkeyPrefsKey, (int)(KeyCode)popup.value); }