protected void doSubstancesGUI(SerializedObject ob)
    {
        SerializedProperty voxelSubstances = ob.FindProperty("voxelSubstances");

        showSubstances = doBigFoldout(showSubstances, "Substances");
        if (showSubstances)
        {
            InspectorList.doArrayGUISimple(ref voxelSubstances);
        }
        ob.ApplyModifiedProperties();
    }
    protected void doMaskGUI(Vox.VoxelEditor editor)
    {
        editor.maskDisplayAlpha = doSliderFloatField("Mask Display Transparency", editor.maskDisplayAlpha, 0, 1);

        // mask list
        showMasks = doBigFoldout(showMasks, "Masks");
        if (showMasks)
        {
            SerializedProperty voxelMasks = serializedObject.FindProperty("masks");
            // EditorGUILayout.PropertyField(voxelMasks, new GUIContent("Sculpting Masks"), true);
            InspectorList.doArrayGUISimple(ref voxelMasks);
        }
    }
Exemple #3
0
    protected void doSculptGUI(Vox.VoxelEditor editor)
    {
        // brush ghost
        editor.ghostBrushAlpha = doSliderFloatField("Brush Ghost Opacity", editor.ghostBrushAlpha, 0, 1);

        editor.gridEnabled = EditorGUILayout.Toggle("Snap to Grid", editor.gridEnabled);
        if (editor.gridEnabled)
        {
            ++EditorGUI.indentLevel;
            editor.gridUseVoxelUnits = EditorGUILayout.Toggle("Use Voxel Units", editor.gridUseVoxelUnits);
            if (editor.gridUseVoxelUnits)
            {
                float voxelSize = editor.baseSize / (1 << editor.maxDetail);
                editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Voxels)", editor.gridSize / voxelSize) * voxelSize;
            }
            else
            {
                editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Meters)", editor.gridSize);
            }
            --EditorGUI.indentLevel;
        }

        // brush list
        GUILayout.Label("Brush", labelBigFont);
        editor.selectedBrush = GUILayout.Toolbar(editor.selectedBrush, brushes, GUILayout.MinHeight(20));

        // brush substance type
        string[] substances = new string[editor.voxelSubstances.Length];
        for (int i = 0; i < substances.Length; ++i)
        {
            substances[i] = editor.voxelSubstances[i].name;
        }

        // brush size
        switch (editor.selectedBrush)
        {
        case 0:
            GUILayout.Label("Hold 'Shift' to subtract.");
            editor.sphereBrushSize     = doSliderFloatField("Sphere Radius (m)", editor.sphereBrushSize, 0, maxBrushSize(editor));
            editor.sphereSubstanceOnly = GUILayout.Toggle(editor.sphereSubstanceOnly, "Change Substance Only");
            GUILayout.Label("Substance", labelBigFont);
            editor.sphereBrushSubstance = (byte)GUILayout.SelectionGrid(editor.sphereBrushSubstance, substances, 1);
            break;

        case 1:
            GUILayout.Label("Hold 'Shift' to subtract.");
            GUILayout.BeginHorizontal();
            GUILayout.Label("Dimensions (m)");
            editor.cubeBrushDimensions.x = EditorGUILayout.FloatField(editor.cubeBrushDimensions.x);
            editor.cubeBrushDimensions.y = EditorGUILayout.FloatField(editor.cubeBrushDimensions.y);
            editor.cubeBrushDimensions.z = EditorGUILayout.FloatField(editor.cubeBrushDimensions.z);
            GUILayout.EndHorizontal();

            editor.cubeSubstanceOnly = GUILayout.Toggle(editor.cubeSubstanceOnly, "Change Substance Only");
            GUILayout.Label("Substance", labelBigFont);
            editor.cubeBrushSubstance = (byte)GUILayout.SelectionGrid(editor.cubeBrushSubstance, substances, 1);
            break;

        case 2:
            editor.smoothBrushSize       = doSliderFloatField("Radius (m)", editor.smoothBrushSize, 0, maxBrushSize(editor));
            editor.smoothBrushStrength   = doSliderFloatField("Strength", editor.smoothBrushStrength, 0, 5);
            editor.smoothBrushBlurRadius = EditorGUILayout.IntField("Blur Radius", editor.smoothBrushBlurRadius);
            break;
        }

        // PATH GUI
        if (editor.selectedBrush != 0 && editor.selectedBrush != 1)
        {
            return;
        }
        GUILayout.Label("Path Tool", labelBigFont);


        if (editor.pathPoints != null && editor.pathPoints.Length > 0)
        {
            GUILayout.Label("Hold 'Control' to place another point.");
            editor.showPositionHandles = GUILayout.Toggle(editor.showPositionHandles, "Show drag handles (disable click to complete).");
            SerializedProperty prop = serializedObject.FindProperty("pathPoints");
            InspectorList.doArrayGUISimple(ref prop);
            serializedObject.ApplyModifiedProperties();
            if (GUILayout.Button("Clear Path"))
            {
                editor.pathPoints = null;
            }
            else if (GUILayout.Button("Apply Path"))
            {
                Vox.LocalMutator mut = (Vox.LocalMutator)buildMutator(editor, editor.pathPoints[0]);
                if (editor.pathPoints.Length > 1)
                {
                    new Vox.LineMutator(editor.pathPoints, mut).apply(editor);
                }
                else
                {
                    mut.apply(editor);
                }
            }
        }
        else
        {
            GUILayout.Label("Hold 'Control' to start a path.");
            if (GUILayout.Button("Start Path"))
            {
                editor.addPathPoint(editor.transform.position);
            }
        }
    }