Esempio n. 1
0
    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();
    }
Esempio n. 2
0
    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();
    }
Esempio n. 3
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();
    }