Exemplo n.º 1
0
    //Copies all the properties of one gradient onto another
    public void mimic(BiomeColorGradient gradient)
    {
        forceClear();
        blendMode = gradient.blendMode;
        randomizeNewLayerColors = gradient.randomizeNewLayerColors;

        for (int i = 0; i < gradient.numberOfLayers; i++)
        {
            addLayer(gradient.getlayer(i).Color, gradient.getlayer(i).upperBound);
        }
    }
Exemplo n.º 2
0
    void Draw()
    {
        //Drawing the gradient bar
        gradientPreviewRect = new Rect(marginSize, marginSize, position.width - marginSize * 2, 25);
        GUI.DrawTexture(gradientPreviewRect, biomeGradient.GetTexture((int)gradientPreviewRect.width));

        //Drawing the current layer keys as small rects
        keyRects = new Rect[biomeGradient.numberOfLayers];

        for (int i = 0; i < biomeGradient.numberOfLayers; i++)
        {
            BiomeColorGradient.TerrainLayer layer = biomeGradient.getlayer(i);
            Rect layerKeyRect = new Rect(
                gradientPreviewRect.x + gradientPreviewRect.width * layer.upperBound - layerKeyWidth / 2,
                gradientPreviewRect.yMax + marginSize,
                layerKeyWidth,
                layerKeyHeight);

            //Drawing a border for the selected key (just a larger rect behind it
            if (selectedKeyIndex == i)
            {
                EditorGUI.DrawRect(new Rect(layerKeyRect.x - 2, layerKeyRect.y - 2, layerKeyWidth + 4, layerKeyHeight + 4), Color.black);
            }

            EditorGUI.DrawRect(layerKeyRect, layer.Color);
            keyRects[i] = layerKeyRect;
        }

        //Drawing the settings pane
        Rect settingsRect = new Rect(marginSize, keyRects[0].yMax + marginSize, position.width - marginSize * 2, position.height);

        //GUILayout.BeginArea makes it easy to draw anything between it and EndArea
        GUILayout.BeginArea(settingsRect);

        EditorGUI.BeginChangeCheck(); //Listens for changes in fields between here and endChangeCheck
        Color newLayerColor = EditorGUILayout.ColorField(biomeGradient.getlayer(selectedKeyIndex).Color);

        if (EditorGUI.EndChangeCheck())
        {
            biomeGradient.updateLayerColor(selectedKeyIndex, newLayerColor);
            redrawEditorNoiseMap();
        }

        EditorGUI.BeginChangeCheck();
        float newBound = EditorGUILayout.FloatField(biomeGradient.getlayer(selectedKeyIndex).upperBound);

        if (EditorGUI.EndChangeCheck())
        {
            recordUndo();
            Mathf.Clamp01(newBound);
            selectedKeyIndex = biomeGradient.updateLayerBound(selectedKeyIndex, newBound);
            redrawEditorNoiseMap();
        }

        EditorGUI.BeginChangeCheck();
        biomeGradient.blendMode = (BiomeColorGradient.colorBlendMode)EditorGUILayout.EnumPopup("Blend Mode", biomeGradient.blendMode);
        biomeGradient.randomizeNewLayerColors = EditorGUILayout.Toggle("Randomize New Layers", biomeGradient.randomizeNewLayerColors);
        if (EditorGUI.EndChangeCheck())
        {
            redrawEditorNoiseMap();
        }

        GUILayout.Label("Backspace to delete layers.\nUse arrow buttons to select layers, or click their keys.\nClick empty space to dreate a new layer.");

        GUILayout.Label("Undo States Available: " + undoStack.Count);
        if (GUILayout.Button("Undo"))
        {
            undo();
        }

        GUILayout.EndArea();
    }