示例#1
0
    public override void OnInspectorGUI()
    {
        labelBigFont             = new GUIStyle(GUI.skin.label);
        labelBigFont.margin      = new RectOffset(labelBigFont.margin.left, labelBigFont.margin.right, labelBigFont.margin.top + 10, labelBigFont.margin.bottom);
        labelBigFont.fontSize    = 16;
        foldoutBigFont           = new GUIStyle(EditorStyles.foldout);
        foldoutBigFont.margin    = new RectOffset(foldoutBigFont.margin.left, foldoutBigFont.margin.right, foldoutBigFont.margin.top + 10, foldoutBigFont.margin.bottom);
        foldoutBigFont.fontSize  = 16;
        foldoutBigFont.alignment = TextAnchor.LowerLeft;
        buttonBigFont            = new GUIStyle(GUI.skin.button);
        buttonBigFont.fontSize   = 14;
        tabsBigFont             = new GUIStyle(GUI.skin.button);
        tabsBigFont.fixedHeight = 30;

        Vox.VoxelEditor editor = (Vox.VoxelEditor)target;

        if (editor.generating())
        {
            string label = "Generating Skin...";
            EditorGUI.ProgressBar(GUILayoutUtility.GetRect(new GUIContent(label), GUI.skin.button),
                                  VoxelEditorProgressController.getGenerationProgress(editor), label);
            Repaint();
            return;
        }

        serializedObject.Update();

        if (setupGeneration)
        {
            doGenerationGUI(editor);
            return;
        }
        else
        {
            if (!editor.hasVoxelData())
            {
                GUI.enabled = false;
            }
            editor.selectedMode = GUILayout.Toolbar(editor.selectedMode, modes, tabsBigFont, GUILayout.Height(30));
            GUI.enabled         = true;

            switch (editor.selectedMode)
            {
            case 0:
                doManageGUI(editor);
                break;

            case 1:
                doSculptGUI(editor);
                break;

            case 2:
                doMaskGUI(editor);
                break;
            }
        }

        // finally, apply the changes
        serializedObject.ApplyModifiedProperties();
    }
示例#2
0
    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);
        }
    }