コード例 #1
0
        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"))
                        {
                            EditorGUILayout.PropertyField(field);
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            StylisticFog targetInstance = (StylisticFog)target;

            serializedObject.Update();

            foreach (var setting in m_TopLevelFields)
            {
                EditorGUILayout.PropertyField(setting);
            }

            foreach (var group in m_GroupFields)
            {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.Space();

                var  groupProperty = serializedObject.FindProperty(group.name);
                var  enabledField  = group.properties.FirstOrDefault(x => x.propertyPath == group.name + ".enabled");
                bool display       = EditorGUIHelper.Header(groupProperty, enabledField);
                if (!display)
                {
                    serializedObject.ApplyModifiedProperties();
                    continue;
                }
                EditorGUI.indentLevel++;

                foreach (var field in group.properties.Where(x => x.propertyPath != group.name + ".enabled"))
                {
                    EditorGUILayout.PropertyField(field);
                }

                if (group.distanceFog)
                {
                    distanceFogColorDisplay.OnInspectorGUI(targetInstance.distanceFog.colorSelectionType, targetInstance.distanceColorSource);
                }

                if (group.heightFog)
                {
                    heightFogColorDisplay.OnInspectorGUI(targetInstance.heightFog.colorSelectionType, targetInstance.heightColorSource);
                }

                EditorGUI.indentLevel--;

                serializedObject.ApplyModifiedProperties();

                if (EditorGUI.EndChangeCheck())
                {
                    targetInstance.UpdateProperties();
                }
            }
        }
コード例 #3
0
        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"))
                        {
                            if (group.Key.FieldType == typeof(LensAberrations.VignetteSettings))
                            {
                                if (m_SimpleProperties.Contains(field) && concreteTarget.vignette.mode != LensAberrations.SettingsMode.Simple ||
                                    m_AdvancedProperties.Contains(field) && concreteTarget.vignette.mode != LensAberrations.SettingsMode.Advanced)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                if (m_AdvancedProperties.Contains(field) && concreteTarget.chromaticAberration.mode != LensAberrations.SettingsMode.Advanced)
                                {
                                    continue;
                                }
                            }

                            EditorGUILayout.PropertyField(field);
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
        }
コード例 #4
0
        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;
                            }

                            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();
            }
        }