private void DrawFields() { foreach (var group in m_GroupFields) { var enabledField = group.Value.FirstOrDefault(x => x.propertyPath == group.Key.Name + ".enabled"); var groupProperty = serializedObject.FindProperty(group.Key.Name); GUILayout.Space(5); bool display = EditorGUIHelper.Header(groupProperty, enabledField); if (!display) { continue; } GUILayout.BeginHorizontal(); { GUILayout.Space(10); GUILayout.BeginVertical(); { GUILayout.Space(3); foreach (var field in group.Value.Where(x => x.propertyPath != group.Key.Name + ".enabled")) { // Special case for the tonemapping curve field //if (group.Key.FieldType == typeof(TonemappingColorGrading.TonemappingSettings) && // field.propertyType == SerializedPropertyType.AnimationCurve && // concreteTarget.tonemapping.tonemapper != TonemappingColorGrading.Tonemapper.Curve) // continue; // Special case for the neutral tonemapper bool neutralParam = field.name.StartsWith("neutral"); //if (group.Key.FieldType == typeof(TonemappingColorGrading.TonemappingSettings) && // concreteTarget.tonemapping.tonemapper != TonemappingColorGrading.Tonemapper.Neutral && // neutralParam) // continue; if (neutralParam) { EditorGUILayout.PropertyField(field, new GUIContent(ObjectNames.NicifyVariableName(field.name.Substring(7)))); } else { EditorGUILayout.PropertyField(field); } } // Bake button if (group.Key.FieldType == typeof(TonemappingColorGrading.ColorGradingSettings)) { EditorGUI.BeginDisabledGroup(!enabledField.boolValue); if (GUILayout.Button("Export LUT as PNG", EditorStyles.miniButton)) { string path = EditorUtility.SaveFilePanelInProject("Export LUT as PNG", "LUT.png", "png", "Please enter a file name to save the LUT texture to"); if (!string.IsNullOrEmpty(path)) { Texture2D lut = concreteTarget.BakeLUT(); if (!concreteTarget.isGammaColorSpace) { var pixels = lut.GetPixels(); for (int i = 0; i < pixels.Length; i++) { pixels[i] = pixels[i].linear; } lut.SetPixels(pixels); lut.Apply(); } byte[] bytes = lut.EncodeToPNG(); System.IO.File.WriteAllBytes(path, bytes); DestroyImmediate(lut); AssetDatabase.Refresh(); TextureImporter importer = (TextureImporter)AssetImporter.GetAtPath(path); SetLUTImportSettings(importer); } } EditorGUI.EndDisabledGroup(); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } }