void Draw()
    {
        gradientPreviewRect = new Rect(borderSize, borderSize, position.width - borderSize * 2f, 25f);
        GUI.DrawTexture(gradientPreviewRect, gradient.GetTexture((int)gradientPreviewRect.width));

        keyRects = new Rect[gradient.KeyCount];
        for (int i = 0; i < gradient.KeyCount; i++)
        {
            CustomGradient.ColorKey key = gradient.GetKey(i);
            Rect keyRect = new Rect(gradientPreviewRect.x + gradientPreviewRect.width * key.time - keyWidth / 2f, gradientPreviewRect.yMax + borderSize, keyWidth, keyHeight);

            if (i == selectedKeyIndex)
            {
                EditorGUI.DrawRect(new Rect(keyRect.x - 2, keyRect.y - 2, keyRect.width + 4, keyRect.height + 4), Color.black);
            }
            EditorGUI.DrawRect(keyRect, key.color);
            keyRects[i] = keyRect;
        }

        Rect settingRect = new Rect(borderSize, keyRects[0].yMax + borderSize, position.width - borderSize * 2f, position.height);

        GUILayout.BeginArea(settingRect);
        EditorGUI.BeginChangeCheck();
        Color newColor = EditorGUILayout.ColorField(gradient.GetKey(selectedKeyIndex).color);

        if (EditorGUI.EndChangeCheck())
        {
            gradient.UpdateKeyColor(selectedKeyIndex, newColor);
        }
        GUILayout.EndArea();
    }
Beispiel #2
0
    private void Draw()
    {
        gradientPreviewRect = new Rect(BORDER_SIZE, BORDER_SIZE, position.width - BORDER_SIZE * 2, 25);
        GUI.DrawTexture(gradientPreviewRect, gradient.GetTexture((int)gradientPreviewRect.width));

        keyRects = new Rect[gradient.KeyCount];
        for (int i = 0; i < gradient.KeyCount; i++)
        {
            ColorKey key     = gradient.GetKey(i);
            float    keyX    = gradientPreviewRect.x + gradientPreviewRect.width * key.Time - KEY_WIDTH / 2f;
            float    keyY    = gradientPreviewRect.yMax + BORDER_SIZE;
            Rect     keyRect = new Rect(keyX, keyY, KEY_WIDTH, KEY_HEIGHT);

            if (i == selectedKeyIndex)
            {
                EditorGUI.DrawRect(new Rect(keyRect.x - 2, keyRect.y - 2, keyRect.width + 4, keyRect.height + 4), Color.black);
            }
            EditorGUI.DrawRect(keyRect, key.Col);
            keyRects[i] = keyRect;
        }

        Rect settingsRect = new Rect(BORDER_SIZE, keyRects[0].yMax + BORDER_SIZE, position.width - BORDER_SIZE * 2, position.height - BORDER_SIZE * 9);

        GUILayout.BeginArea(settingsRect);
        EditorGUI.BeginChangeCheck();
        Color newCol = EditorGUILayout.ColorField(gradient.GetKey(selectedKeyIndex).Col);

        if (EditorGUI.EndChangeCheck())
        {
            gradient.UpdateKeyColor(selectedKeyIndex, newCol);
        }
        gradient.blendMode      = (BlendMode)EditorGUILayout.EnumPopup("Blend Mode", gradient.blendMode);
        gradient.randomizeColor = EditorGUILayout.Toggle("Randmize Color", gradient.randomizeColor);
        GUILayout.EndArea();
    }
    void Draw()
    {
        gradientPreviewRect = new Rect(borderSize, borderSize, position.width - borderSize * 2, 25);
        GUI.DrawTexture(gradientPreviewRect, gradient.GetTexture((int)gradientPreviewRect.width));

        keyRects = new Rect[gradient.NumKeys];

        for (int i = 0; i < gradient.NumKeys; i++)
        {
            CustomGradient.ColorKey key = gradient.GetKey(i);
            Rect keyRect = new Rect(gradientPreviewRect.x + gradientPreviewRect.width * key.Time - keyWidth / 2f, gradientPreviewRect.yMax + borderSize, keyWidth, keyHeight);
            if (i == selectedKeyIndex)
            {
                EditorGUI.DrawRect(new Rect(keyRect.x - 2, keyRect.y - 2, keyRect.width + 4, keyRect.height + 4), Color.black);
            }

            EditorGUI.DrawRect(keyRect, key.Color);
            keyRects[i] = keyRect;
        }

        Rect settingsRect = new Rect(borderSize, keyRects[0].yMax + borderSize, position.width - borderSize * 2, position.height);

        GUILayout.BeginArea(settingsRect);
        EditorGUI.BeginChangeCheck();
        Color newColor = EditorGUILayout.ColorField(gradient.GetKey(selectedKeyIndex).Color);

        if (EditorGUI.EndChangeCheck())
        {
            gradient.UpdateKeyColor(selectedKeyIndex, newColor);
        }
        gradient.blendMode      = (CustomGradient.BlendMode)EditorGUILayout.EnumPopup("Blend mode", gradient.blendMode);
        gradient.randomizeColor = EditorGUILayout.Toggle("Randomize Color", gradient.randomizeColor);
        GUILayout.EndArea();
    }
Beispiel #4
0
    private void Draw()
    {
        _gradientPreviewRect = new Rect(BorderSize, BorderSize, position.width - (BorderSize * 2), gradientPreviewRectHeight);
        GUI.DrawTexture(_gradientPreviewRect, _gradient.GetTexture((int)_gradientPreviewRect.width));
        _keyRects = new Rect[_gradient.NumKeys];

        for (int i = 0; i < _gradient.NumKeys; i++)
        {
            CustomGradient.ColorKey key = _gradient.GetKey(i);
            Rect keyRect = new Rect(_gradientPreviewRect.x + (_gradientPreviewRect.width * key.Time) - (_keyWidth / 2f),
                                    _gradientPreviewRect.yMax + BorderSize, _keyWidth, _keyHeight);

            if (i == _selectedKeyIndex)
            {
                EditorGUI.DrawRect(new Rect(keyRect.x - 3, keyRect.y - 3, keyRect.width + 6, keyRect.height + 6), Color.black);
            }

            EditorGUI.DrawRect(keyRect, key.Color);
            _keyRects[i] = keyRect;
        }

        Rect settingsRect = new Rect(BorderSize, _keyRects[0].yMax + BorderSize,
                                     position.width - (BorderSize * 2), position.height);

        GUILayout.BeginArea(settingsRect);
        EditorGUI.BeginChangeCheck();
        Color newColor = EditorGUILayout.ColorField(_gradient.GetKey(_selectedKeyIndex).Color);

        if (EditorGUI.EndChangeCheck())
        {
            _gradient.UpdateKeyColor(_selectedKeyIndex, newColor);
        }
        _gradient.blendMode      = (CustomGradient.BlendMode)EditorGUILayout.EnumPopup("Blend Mode", _gradient.blendMode);
        _gradient.randomizeColor = EditorGUILayout.Toggle("Randomize Color", _gradient.randomizeColor);
        GUILayout.EndArea();
    }