Пример #1
0
        private void DrawButtonGUI()
        {
            // Generate button
            GUILayout.Space(10);
            GUIContent generateButton = ContentText.generateNoiseButton;

            switch (CurrentPattern.Type)
            {
            case PatternType.Noise:
                generateButton = ContentText.generateNoiseButton;
                break;

            case PatternType.Dots:
                generateButton = ContentText.generateDotsButton;
                break;

            case PatternType.Lines:
                generateButton = ContentText.generateLinesButton;
                break;

            default:
                Debug.LogWarningFormat(ContentText.buttonMissingPatternTypeWarning, CurrentPattern.Type);
                break;
            }
            if (GUILayout.Button(generateButton))
            {
                Generate(CurrentPattern);
                BeffioDitherEditorUtilities.UpdateMaterialsForTexture(_pattern.Texture);
                CurrentPattern.IsDirty = false;
            }
        }
Пример #2
0
        /* EDITOR DRAWING */
        #region Editor Drawing
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Branding
            BeffioDitherEditorUtilities.DrawInspectorBranding();
            GUILayout.Space(10);

            // Cache dirty state to prevent layouting error
            bool isDirty = CurrentPattern.IsDirty;

            // Settings
            EditorGUI.BeginChangeCheck();
            {
                // Texture Settings
                DrawTextureSettingGUI();

                // Type Selection
                DrawPatternTypeSelectionGUI();

                // Pattern Settings
                DrawPatternSettingsGUI();

                // Apply changes to serializedObject
                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    if (_autoGenerate)
                    {
                        Generate(CurrentPattern);
                        BeffioDitherEditorUtilities.UpdateMaterialsForTexture(_pattern.Texture);
                        CurrentPattern.IsDirty = false;
                    }
                    else
                    {
                        CurrentPattern.IsDirty = true;
                    }
                }
            }

            // Buttons
            DrawButtonGUI();

            // Help Message
            if (isDirty)
            {
                EditorGUILayout.HelpBox(ContentText.notGeneratedHelpBox, MessageType.Warning);
            }
        }
Пример #3
0
        private void DrawButtonsGUI()
        {
            // Generate Button
            if (GUILayout.Button(ContentText.generateFromListButton))
            {
                GeneratePaletteTexture(CurrentPalette);
                BeffioDitherEditorUtilities.UpdateMaterialsForTexture(_palette.Texture);
                CurrentPalette.IsDirty = false;
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Random color generation", EditorStyles.boldLabel);
            //EditorGUILayout.LabelField("_______________________________________________________________________________________________________________");

            // Randomize colors button
            if (GUILayout.Button(ContentText.randomizeColors))
            {
                for (int i = 0; i < CurrentPalette.Colors.Count; i++)
                {
                    if (!_randomBW && !_selectiveRandomization)
                    {
                        CurrentPalette.Colors[i] = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
                    }
                    else if (_randomBW)
                    {
                        v = UnityEngine.Random.Range(0f, 1f);
                        CurrentPalette.Colors[i] = new Color(v, v, v);
                    }
                    else if (!_randomBW && _selectiveRandomization)
                    {
                        if (_r && _g && _b)
                        {
                            CurrentPalette.Colors[i] = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
                        }
                        else if (!_r && _g && _b)
                        {
                            CurrentPalette.Colors[i] = new Color(CurrentPalette.Colors[i].r, UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
                        }
                        else if (_r && !_g && _b)
                        {
                            CurrentPalette.Colors[i] = new Color(UnityEngine.Random.Range(0f, 1f), CurrentPalette.Colors[i].g, UnityEngine.Random.Range(0f, 1f));
                        }
                        else if (_r && _g && !_b)
                        {
                            CurrentPalette.Colors[i] = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), CurrentPalette.Colors[i].b);
                        }
                        else if (!_r && _g && !_b)
                        {
                            CurrentPalette.Colors[i] = new Color(CurrentPalette.Colors[i].r, UnityEngine.Random.Range(0f, 1f), CurrentPalette.Colors[i].b);
                        }
                        else if (_r && !_g && !_b)
                        {
                            CurrentPalette.Colors[i] = new Color(UnityEngine.Random.Range(0f, 1f), CurrentPalette.Colors[i].g, CurrentPalette.Colors[i].b);
                        }
                        else if (!_r && !_g && _b)
                        {
                            CurrentPalette.Colors[i] = new Color(CurrentPalette.Colors[i].r, CurrentPalette.Colors[i].g, UnityEngine.Random.Range(0f, 1f));
                        }
                        else if (!_r && !_g && !_b)
                        {
                            CurrentPalette.Colors[i] = new Color(CurrentPalette.Colors[i].r, CurrentPalette.Colors[i].g, CurrentPalette.Colors[i].b);
                        }
                    }
                }

                GeneratePaletteTexture(CurrentPalette);
                BeffioDitherEditorUtilities.UpdateMaterialsForTexture(_palette.Texture);
                CurrentPalette.IsDirty = false;
            }
        }
Пример #4
0
        /* EDITOR DRAWING */
        #region Editor Drawing
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Branding
            BeffioDitherEditorUtilities.DrawInspectorBranding();
            GUILayout.Space(10);

            // Cache dirty and texture states to prevent layouting error
            bool hasTexture = CurrentPalette.HasTexture;
            bool isDirty    = CurrentPalette.IsDirty;

            EditorGUI.BeginChangeCheck();
            {
                // Settings
                DrawSettingsGUI();

                // Color List
                DrawColorListGUI();

                // Apply Changes to serializedObject
                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    if (_autoGenerate)
                    {
                        GeneratePaletteTexture(CurrentPalette);
                        BeffioDitherEditorUtilities.UpdateMaterialsForTexture(_palette.Texture);
                        CurrentPalette.IsDirty = false;
                    }
                    else
                    {
                        CurrentPalette.IsDirty = true;
                    }
                }
            }

            GUILayout.Space(10);

            // Auto generate checkbox
            _autoGenerate = EditorGUILayout.Toggle(ContentText.autoGenerate, _autoGenerate);

            // Buttons
            DrawButtonsGUI();

            // BW randomization checkbox
            _randomBW = EditorGUILayout.Toggle(ContentText.randomizeColorsBW, _randomBW);
            if (!_randomBW)
            {
                _selectiveRandomization = EditorGUILayout.Toggle(ContentText.selectiveRandomization, _selectiveRandomization);
                if (_selectiveRandomization)
                {
                    EditorGUI.indentLevel = 1;
                    _r = EditorGUILayout.Toggle("R", _r);
                    _g = EditorGUILayout.Toggle("G", _g);
                    _b = EditorGUILayout.Toggle("B", _b);
                    EditorGUI.indentLevel = 0;
                }
            }

            // Help Messages
            DrawHelpBoxGUI(hasTexture, isDirty);
        }