protected void doGeneralPropertiesGUI(VoxelEditorParameters editor)
 {
     editor.createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
     editor.useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
     editor.saveMeshes      = EditorGUILayout.Toggle(new GUIContent("Save Meshes To Scene"), editor.saveMeshes);
     editor.reduceMeshes    = EditorGUILayout.Toggle(new GUIContent("Reduce Meshes"), editor.reduceMeshes);
     if (editor.reduceMeshes)
     {
         editor.reductionAmount = doSliderFloatField("Mesh Reduction Level", editor.reductionAmount, 0, 0.5f);
     }
 }
    protected void doTreeSizeGUI(VoxelEditorParameters editor)
    {
        // world detail
        int maxDetail = EditorGUILayout.IntField("Voxel Power", editor.maxDetail);

        if (maxDetail > 16)
        {
            maxDetail = 16;
        }
        else if (maxDetail < 4)
        {
            maxDetail = 4;
        }
        editor.maxDetail = (byte)maxDetail;

        long dimension = 1 << editor.maxDetail;

        ++EditorGUI.indentLevel;
        EditorGUILayout.LabelField("Voxels Per Side", dimension.ToString(numFormInt));
        EditorGUILayout.LabelField("Max Voxel Count", Mathf.Pow(dimension, 3).ToString(numFormInt));
        --EditorGUI.indentLevel;
        EditorGUILayout.Separator();

        // world dimension
        editor.baseSize = EditorGUILayout.FloatField("World Size (m)", editor.baseSize);
        if (editor.baseSize < 0)
        {
            editor.baseSize = 0;
        }
        ++EditorGUI.indentLevel;
        EditorGUILayout.LabelField("World Area", Mathf.Pow(editor.baseSize / 1000, 2).ToString(numForm) + " square km");
        EditorGUILayout.LabelField("World Volume", Mathf.Pow(editor.baseSize / 1000, 3).ToString(numForm) + " cubic km");
        --EditorGUI.indentLevel;
        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Voxel Size", (editor.baseSize / dimension).ToString(numForm) + " m");
        EditorGUILayout.Separator();
    }
    protected void doTreeSizeGUI(VoxelEditorParameters editor)
    {
        // world detail
        int maxDetail = EditorGUILayout.IntField("Voxel Power", editor.maxDetail);
        if (maxDetail > 16)
            maxDetail = 16;
        else if (maxDetail < 4)
            maxDetail = 4;
        editor.maxDetail = (byte)maxDetail;

        long dimension = 1 << editor.maxDetail;
        ++EditorGUI.indentLevel;
        EditorGUILayout.LabelField("Voxels Per Side", dimension.ToString(numFormInt));
        EditorGUILayout.LabelField("Max Voxel Count", Mathf.Pow(dimension, 3).ToString(numFormInt));
        --EditorGUI.indentLevel;
        EditorGUILayout.Separator();

        // world dimension
        editor.baseSize = EditorGUILayout.FloatField("World Size (m)", editor.baseSize);
        if (editor.baseSize < 0)
            editor.baseSize = 0;
        ++EditorGUI.indentLevel;
        EditorGUILayout.LabelField("World Area", Mathf.Pow(editor.baseSize / 1000, 2).ToString(numForm) + " square km");
        EditorGUILayout.LabelField("World Volume", Mathf.Pow(editor.baseSize / 1000, 3).ToString(numForm) + " cubic km");
        --EditorGUI.indentLevel;
        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Voxel Size", (editor.baseSize / dimension).ToString(numForm) + " m");
        EditorGUILayout.Separator();
    }
    protected void doManageGUI(Vox.VoxelEditor editor)
    {
        // actions
        GUILayout.Label ("Actions", labelBigFont);
        if (GUILayout.Button("Generate New")) {
            setupGeneration = true;
            generationParameters = new VoxelEditorParameters();
            generationParameters.setFrom(editor);
        }
        if (editor.hasVoxelData()) {
            if (GUILayout.Button("Erase")) {
                if (EditorUtility.DisplayDialog("Erase Voxels?", "Are you sure you want to erase all voxel data?", "Erase", "Cancel")) {
                    editor.wipe();
                }
            }
            if (GUILayout.Button(editor.hasRenderers()? "Reskin": "Skin", buttonBigFont) && validateSubstances(editor)) {
                editor.generateRenderers();
            }
            if (editor.hasRenderers() && GUILayout.Button("Clear Skin") && validateSubstances(editor)) {
                editor.clearRenderers();
            }
            if (GUILayout.Button("Export")) {
                editor.export(EditorUtility.SaveFilePanel("Choose File to Export To", "", "Voxels", "vox"));
            }
        }
        if (GUILayout.Button("Import")) {
            if (!editor.import(EditorUtility.OpenFilePanel("Choose File to Import From", "", "vox"))) {
                EditorUtility.DisplayDialog("Wrong Voxel Format", "The file you chose was an unknown or incompatible voxel format version.", "OK");
            }
        }

        if (!editor.hasVoxelData())
            return;

        GUILayout.Label("Properties", labelBigFont);

        doGeneralPropertiesGUI(editor);

        // TODO: implement LOD and uncomment this
        //		// LOD
        //		SerializedProperty useLod = ob.FindProperty("useLod");
        //		EditorGUILayout.PropertyField(useLod, new GUIContent("Use Level of Detail"));
        //		if (useLod.boolValue) {
        //			++EditorGUI.indentLevel;
        //			SerializedProperty lodDetail = ob.FindProperty("lodDetail");
        //			EditorGUILayout.PropertyField(lodDetail, new GUIContent("Target Level of Detail"));
        //			if (lodDetail.floatValue > 1000)
        //				lodDetail.floatValue = 1000;
        //			else if (lodDetail.floatValue < 0.1f)
        //				lodDetail.floatValue = 0.1f;
        //
        //			SerializedProperty curLodDetail = ob.FindProperty("curLodDetail");
        //			if (Application.isPlaying) {
        //				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Current Level of Detail"));
        //			} else {
        //				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Starting Level of Detail"));
        //			}
        //
        //			if (curLodDetail.floatValue > 1000)
        //				curLodDetail.floatValue = 1000;
        //			else if (curLodDetail.floatValue < 0.1f)
        //				curLodDetail.floatValue = 0.1f;
        //			--EditorGUI.indentLevel;
        //		}

        // do substances
        doSubstancesGUI(serializedObject);

        // show statistics
        showStatistics = doBigFoldout(showStatistics, "Statistics");
        if (showStatistics) {
            EditorGUILayout.LabelField("Chunk Count: " + editor.renderers.Count);
            doTreeSizeGUI(editor);
            EditorGUILayout.LabelField("Vertex Count: " + editor.vertexCount);
            EditorGUILayout.LabelField("Triangle Count: " + editor.triangleCount);
        }
    }
 protected void doGeneralPropertiesGUI(VoxelEditorParameters editor)
 {
     editor.createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
     editor.useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
     editor.saveMeshes = EditorGUILayout.Toggle(new GUIContent("Save Meshes To Scene"), editor.saveMeshes);
     editor.reduceMeshes = EditorGUILayout.Toggle(new GUIContent("Reduce Meshes"), editor.reduceMeshes);
     if (editor.reduceMeshes) {
         editor.reductionAmount = doSliderFloatField("Mesh Reduction Level", editor.reductionAmount, 0, 0.5f);
     }
 }
    protected void doManageGUI(Vox.VoxelEditor editor)
    {
        // actions
        GUILayout.Label("Actions", labelBigFont);
        if (GUILayout.Button("Generate New"))
        {
            setupGeneration      = true;
            generationParameters = new VoxelEditorParameters();
            generationParameters.setFrom(editor);
        }
        if (editor.hasVoxelData())
        {
            if (GUILayout.Button("Erase"))
            {
                if (EditorUtility.DisplayDialog("Erase Voxels?", "Are you sure you want to erase all voxel data?", "Erase", "Cancel"))
                {
                    editor.wipe();
                }
            }
            if (GUILayout.Button(editor.hasRenderers()? "Reskin": "Skin", buttonBigFont) && validateSubstances(editor))
            {
                editor.generateRenderers();
            }
            if (editor.hasRenderers() && GUILayout.Button("Clear Skin") && validateSubstances(editor))
            {
                editor.clearRenderers();
            }
            if (GUILayout.Button("Export"))
            {
                editor.export(EditorUtility.SaveFilePanel("Choose File to Export To", "", "Voxels", "vox"));
            }
        }
        if (GUILayout.Button("Import"))
        {
            if (!editor.import(EditorUtility.OpenFilePanel("Choose File to Import From", "", "vox")))
            {
                EditorUtility.DisplayDialog("Wrong Voxel Format", "The file you chose was an unknown or incompatible voxel format version.", "OK");
            }
        }

        if (!editor.hasVoxelData())
        {
            return;
        }

        GUILayout.Label("Properties", labelBigFont);

        doGeneralPropertiesGUI(editor);

        // TODO: implement LOD and uncomment this
//		// LOD
//		SerializedProperty useLod = ob.FindProperty("useLod");
//		EditorGUILayout.PropertyField(useLod, new GUIContent("Use Level of Detail"));
//		if (useLod.boolValue) {
//			++EditorGUI.indentLevel;
//			SerializedProperty lodDetail = ob.FindProperty("lodDetail");
//			EditorGUILayout.PropertyField(lodDetail, new GUIContent("Target Level of Detail"));
//			if (lodDetail.floatValue > 1000)
//				lodDetail.floatValue = 1000;
//			else if (lodDetail.floatValue < 0.1f)
//				lodDetail.floatValue = 0.1f;
//
//			SerializedProperty curLodDetail = ob.FindProperty("curLodDetail");
//			if (Application.isPlaying) {
//				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Current Level of Detail"));
//			} else {
//				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Starting Level of Detail"));
//			}
//
//			if (curLodDetail.floatValue > 1000)
//				curLodDetail.floatValue = 1000;
//			else if (curLodDetail.floatValue < 0.1f)
//				curLodDetail.floatValue = 0.1f;
//			--EditorGUI.indentLevel;
//		}

        // do substances
        doSubstancesGUI(serializedObject);


        // show statistics
        showStatistics = doBigFoldout(showStatistics, "Statistics");
        if (showStatistics)
        {
            EditorGUILayout.LabelField("Chunk Count: " + editor.renderers.Count);
            doTreeSizeGUI(editor);
            EditorGUILayout.LabelField("Vertex Count: " + editor.vertexCount);
            EditorGUILayout.LabelField("Triangle Count: " + editor.triangleCount);
        }
    }
 protected void doGeneralPropertiesGUI(VoxelEditorParameters editor)
 {
     editor.createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
     editor.useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
 }