示例#1
0
        void Draw()
        {
            gradientPreveiwRect = new Rect(borderSize, borderSize, position.width - (borderSize * 2), 25);

            GUI.DrawTexture(gradientPreveiwRect, gradient.GetTexture((int)gradientPreveiwRect.width));
            keyRects = new Rect[gradient.NumKeys];
            for (int i = 0; i < gradient.NumKeys; i++)
            {
                ColorKey key = gradient.GetKey(i);

                Rect keyRect = new Rect(gradientPreveiwRect.x + gradientPreveiwRect.width * key.Time - (keyWidth / 2f), gradientPreveiwRect.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].y + borderSize + keyHeight, position.width - borderSize * 2, position.height - (borderSize + keyHeight * 4));

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

            if (EditorGUI.EndChangeCheck())
            {
                gradient.UpdateKeyColor(selectedKeyIndex, newcolor);
            }
            // display gradient
            gradient.blendMode      = (MegaGradient.BlendMode)EditorGUILayout.EnumPopup("Blend Mode", gradient.blendMode);
            gradient.randomizeColor = EditorGUILayout.Toggle("Randomize New Color", gradient.randomizeColor);
            GUILayout.EndArea();
        }