void AdvancedSettings() { using (ShapesUI.Group) { GUILayout.Label("Advanced", EditorStyles.boldLabel); if (ShapesUI.CenteredButton(new GUIContent("Regenerate Shaders & Materials", "Generates all shaders and materials in Shapes"))) { CodegenShaders.GenerateShadersAndMaterials(); } if (ShapesUI.CenteredButton(new GUIContent("Regenerate Draw Overloads", "Regenerates all Draw.X overload functions to DrawOverloads.cs"))) { CodegenDrawOverloads.GenerateDrawOverloadsScript(); } } }
void CsharpConfigSettings() { using (new ShapesUI.AssetEditScope(ShapesConfig.Instance)) { using (ShapesUI.Group) { GUILayout.Label("Interface", EditorStyles.boldLabel); EditorGUILayout.PropertyField(useHdrColorPickers, new GUIContent("HDR color pickers")); } using (ShapesUI.Group) { GUILayout.Label("Immediate Mode", EditorStyles.boldLabel); EditorGUILayout.PropertyField(useImmediateModeInstancing, new GUIContent("GPU Instancing")); using (ShapesUI.TempLabelWidth(220)) EditorGUILayout.PropertyField(pushPopStateInDrawCommands, new GUIContent("Always push/pop in Draw.Command")); EditorGUILayout.PropertyField(polylineDefaultPointsPerTurn, new GUIContent("Default polyline density")); EditorGUILayout.PropertyField(polylineBezierAngularSumAccuracy, new GUIContent("Bezier accuracy")); } } }
void ShaderSettings() { using (ShapesUI.Group) { GUILayout.Label("Shader Settings", EditorStyles.boldLabel); using (ShapesUI.TempLabelWidth(160)) { EditorGUILayout.PropertyField(FRAG_OUTPUT_V4, new GUIContent("Output precision")); EditorGUILayout.PropertyField(LOCAL_ANTI_ALIASING_QUALITY, new GUIContent("Local AA quality")); EditorGUILayout.PropertyField(QUAD_INTERPOLATION_QUALITY, new GUIContent("Quad interpolation quality")); EditorGUILayout.PropertyField(NOOTS_ACROSS_SCREEN, new GUIContent("Noots across screen")); } GUILayout.Space(3); if (ShapesUI.CenteredButton(new GUIContent("Apply shader settings", "Apply shader settings"))) { ApplyShaderSettings(); } GUILayout.Space(3); } }
void DrawDetailLevelEntry(SerializedProperty prop, DetailLevel detail, int min, Func <SerializedProperty, int> triCount) { bool isInt2 = prop.propertyType == SerializedPropertyType.Vector2Int; using (ShapesUI.Horizontal) { using (ShapesUI.TempLabelWidth(100)) { using (var chChk = new EditorGUI.ChangeCheckScope()) { if (isInt2) { SerializedProperty x = prop.FindPropertyRelative("x"); SerializedProperty y = prop.FindPropertyRelative("y"); EditorGUILayout.PrefixLabel(new GUIContent(detail.ToString(), "Minor & major axis divisions")); using (new EditorGUI.IndentLevelScope(-2)) { EditorGUILayout.PropertyField(x, GUIContent.none, GUILayout.Width(32)); EditorGUILayout.PropertyField(y, GUIContent.none, GUILayout.Width(32)); } } else { EditorGUILayout.PropertyField(prop, new GUIContent(detail.ToString()), GUILayout.Width(150)); } if (chChk.changed) { // clamp if (isInt2) { prop.vector2IntValue = new Vector2Int(Mathf.Max(min, prop.vector2IntValue.x), Mathf.Max(min, prop.vector2IntValue.y)); } else { prop.intValue = Mathf.Max(min, prop.intValue); } } } } GUILayout.Label($"{triCount( prop )} tris"); } }
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); } } }
void AdvancedSettings() { using (ShapesUI.Group) { GUILayout.Label("Advanced", EditorStyles.boldLabel); if (ShapesUI.CenteredButton(new GUIContent("Regenerate Shaders & Materials", "Generates all shaders and materials in Shapes"))) { CodegenShaders.GenerateShadersAndMaterials(UnityInfo.GetCurrentRenderPipelineInUse()); } if (ShapesUI.CenteredButton(new GUIContent("Regenerate Draw Overloads", "Regenerates all Draw.X overload functions to DrawOverloads.cs"))) { CodegenDrawOverloads.GenerateDrawOverloadsScript(); } if (ShapesUI.CenteredButton(new GUIContent("Regenerate Component Interfaces", "Regenerates all Shape component interfaces"))) { CodegenInterfaces.Generate(); } if (ShapesUI.CenteredButton(new GUIContent("Regenerate IM meta MPBs", "Regenerates all meta-material property blocks for each shape, based on their shader parameters in the core.cginc files"))) { CodegenMpbs.Generate(); } } }