Esempio n. 1
0
    void PrimitiveSettings()
    {
        using (ShapesUI.Group) {
            GUILayout.Label("Primitives", EditorStyles.boldLabel);
            using (new ShapesUI.AssetEditScope(ShapesAssets.Instance)) {
                if (showDetailLevels = EditorGUILayout.Foldout(showDetailLevels, new GUIContent("Detail Levels", "Configure the mesh density of each detail level preset, for every type of Shape that can make use of it")))
                {
                    using (new EditorGUI.IndentLevelScope(1)) {
                        DrawDetailLevelProperties(sphereDetail, "Sphere", TOOLTIP_DETAIL_SPHERE, min: 1, p => PrimitiveGenerator.TriangleCountIcosphere(p.intValue));
                        DrawDetailLevelProperties(torusDivsMinorMajor, "Torus", TOOLTIP_DETAIL_TORUS, min: 3, p => PrimitiveGenerator.TriangleCountTorus(p.vector2IntValue));
                        DrawDetailLevelProperties(coneDivs, "Cone", TOOLTIP_DETAIL_CONE, min: 3, p => PrimitiveGenerator.TriangleCountCone(p.intValue));
                        DrawDetailLevelProperties(cylinderDivs, "Cylinder", TOOLTIP_DETAIL_CYLINDER, min: 3, p => PrimitiveGenerator.TriangleCountCylinder(p.intValue));
                        DrawDetailLevelProperties(capsuleDivs, "Capsule", TOOLTIP_DETAIL_CAPSULE, min: 1, p => PrimitiveGenerator.TriangleCountCapsule(p.intValue));
                    }
                }

                if (showBounds = EditorGUILayout.Foldout(showBounds, new GUIContent("Bounds Sizes", ShapesConfig.TOOLTIP_BOUNDS)))
                {
                    using (new EditorGUI.IndentLevelScope(1)) {
                        EditorGUILayout.PropertyField(boundsSizeSphere, new GUIContent("Sphere"));
                        EditorGUILayout.PropertyField(boundsSizeTorus, new GUIContent("Torus"));
                        EditorGUILayout.PropertyField(boundsSizeCone, new GUIContent("Cone"));
                        EditorGUILayout.PropertyField(boundsSizeCylinder, new GUIContent("Cylinder"));
                        EditorGUILayout.PropertyField(boundsSizeCapsule, new GUIContent("Capsule"));
                        EditorGUILayout.PropertyField(boundsSizeQuad, new GUIContent("Quad"));
                        EditorGUILayout.PropertyField(boundsSizeTriangle, new GUIContent("Triangle"));
                        EditorGUILayout.PropertyField(boundsSizeCuboid, new GUIContent("Cuboid"));
                    }
                }

                GUILayout.Space(3);
                if (ShapesUI.CenteredButton(new GUIContent("Apply & regenerate primitives", "Regenerate all primitive mesh assets using the configuration above")))
                {
                    PrimitiveGenerator.Generate3DPrimitiveAssets();
                }
                GUILayout.Space(3);
            }
        }
    }