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);
        }
    }
Example #2
0
	protected void doGeneralPropertiesGUI(Vox.VoxelEditor editor) {
		bool createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
		bool useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
		bool saveMeshes = EditorGUILayout.Toggle(new GUIContent("Save Meshes To Scene"), editor.saveMeshes);
		bool reduceMeshes = EditorGUILayout.Toggle(new GUIContent("Reduce Meshes"), editor.reduceMeshes);
		float reductionAmount = editor.reductionAmount;
		if (editor.reduceMeshes) {
			reductionAmount = doSliderFloatField("Mesh Reduction Level", editor.reductionAmount, 0, 0.5f);
		}
		byte maxDetail = (byte)EditorGUILayout.IntField(new GUIContent("Voxel Power"), editor.maxDetail);
		if (maxDetail != editor.maxDetail || createColliders != editor.createColliders ||
			saveMeshes != editor.saveMeshes || reductionAmount != editor.reductionAmount ||
			useStaticMeshes != editor.useStaticMeshes || reduceMeshes != editor.reduceMeshes) {
			if (maxDetail != editor.maxDetail) {
				editor.maxDetail = maxDetail;
				editor.setupLookupTables();
			}
			editor.createColliders = createColliders;
			editor.useStaticMeshes = useStaticMeshes;
			editor.saveMeshes = saveMeshes;
            editor.reduceMeshes = reduceMeshes;
			editor.reductionAmount = reductionAmount;
			editor.clearRenderers();
		}
	}