private void OnGUI() { ColorAssistantUtils.DrawHeader(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); var buttonText = _texture == null ? "Import Image" : "Replace Image"; if (GUILayout.Button(buttonText)) { _texture = ColorAssistantUtils.GetTextureFromExplorer(); } if (_texture) { (_width, _texRect) = ColorAssistantUtils.DrawTexture(_texture, _maxHeight); } EditorGUILayout.EndVertical(); if (_texture) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); _tolerance = EditorGUILayout.Slider("Tolerance Filter", _tolerance, 0.1f, 1f); if (GUILayout.Button("Process")) { _tempTex = ColorAssistantUtils.GetCopyTexture(_texture); ProcessTempTexture(); } EditorGUILayout.EndHorizontal(); ColorAssistantUtils.DrawColorPalette(_filteredColors, 200, 20); EditorGUILayout.EndVertical(); } }
private void Debug() { EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (GUILayout.Button("Init Process")) { ProcessInit(); } if (GUILayout.Button("Step")) //_maxSp > _threshold2 { ProcessStep(); } if (_texture) { GUILayout.Label("1. Squared Texture"); ColorAssistantUtils.DrawTexture(_texture); } GUILayout.BeginHorizontal(); _threshold2 = EditorGUILayout.FloatField("Sp Threshold", Mathf.Max(0f, _threshold2)); if (GUILayout.Button("Auto threshold")) { _threshold2 = (_texture.width * _texture.height) / 1000f; } GUILayout.EndHorizontal(); GUILayout.Label("Threshold 2: " + _threshold2.ToString("F1")); if (_binCreatedTex) { GUILayout.Label("2. Create 10x10 Bins From Texture"); ColorAssistantUtils.DrawTexture(_binCreatedTex); } if (_voteTex) { GUILayout.Label("3. Populated votes"); ColorAssistantUtils.DrawTexture(_voteTex); } GUILayout.Label("4. Max voted bin total votes: " + _maxVotedBin.TotalVotes); GUILayout.Label("5. Max sp: " + _maxSp); EditorGUILayout.EndVertical(); }
private void OnGUI() { ColorAssistantUtils.DrawHeader(); //Get Resize and draw texture EditorGUILayout.BeginVertical(EditorStyles.helpBox); var buttonText = _texture == null ? "Import Image" : "Replace Image"; if (GUILayout.Button(buttonText)) { _palette.Clear(); _texture = ColorAssistantUtils.GetTextureFromExplorer(); _originalTexture = Instantiate(_texture); _texture = ColorAssistantUtils.RescaleTexture(_texture, 100, true); _binCreatedTex = null; _voteTex = null; } EditorGUILayout.EndVertical(); _debug = EditorGUILayout.Foldout(_debug, "Debug"); if (_debug) { Debug(); } GUILayout.Space(10); if (_originalTexture) { ColorAssistantUtils.DrawTexture(_originalTexture, 300); } GUILayout.Space(10); GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginHorizontal(); _threshold1 = EditorGUILayout.Slider("Color Difference Threshold", _threshold1, 0f, 1f); if (GUILayout.Button("Auto threshold")) { _threshold1 = 0.45f; } GUILayout.EndHorizontal(); if (GUILayout.Button("Generate Palette")) { ProcessInit(); for (int i = 0; i < 20; i++) { ProcessStep(); if (_maxSp < _threshold2) { break; } } } if (GUILayout.Button("Clear Data")) { _palette.Clear(); } ColorAssistantUtils.DrawColorPalette(_palette, 200, 20); GUILayout.EndVertical(); }