BloomEditor.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (C) 2015, 2016 Keijiro Takahashi
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. // THE SOFTWARE.
  20. //
  21. using UnityEngine;
  22. using UnityEditor;
  23. namespace Max820
  24. {
  25. [CanEditMultipleObjects]
  26. [CustomEditor(typeof(Bloom))]
  27. public class BloomEditor : Editor
  28. {
  29. BloomGraphDrawer _graph;
  30. SerializedProperty _threshold;
  31. SerializedProperty _softKnee;
  32. SerializedProperty _radius;
  33. SerializedProperty _intensity;
  34. SerializedProperty _highQuality;
  35. SerializedProperty _antiFlicker;
  36. static GUIContent _textThreshold = new GUIContent("Threshold (gamma)");
  37. void OnEnable()
  38. {
  39. _graph = new BloomGraphDrawer();
  40. _threshold = serializedObject.FindProperty("_threshold");
  41. _softKnee = serializedObject.FindProperty("_softKnee");
  42. _radius = serializedObject.FindProperty("_radius");
  43. _intensity = serializedObject.FindProperty("_intensity");
  44. _highQuality = serializedObject.FindProperty("_highQuality");
  45. _antiFlicker = serializedObject.FindProperty("_antiFlicker");
  46. }
  47. public override void OnInspectorGUI()
  48. {
  49. serializedObject.Update();
  50. if (!serializedObject.isEditingMultipleObjects) {
  51. EditorGUILayout.Space();
  52. _graph.Prepare((Bloom)target);
  53. _graph.DrawGraph();
  54. EditorGUILayout.Space();
  55. }
  56. EditorGUILayout.PropertyField(_threshold, _textThreshold);
  57. EditorGUILayout.PropertyField(_softKnee);
  58. EditorGUILayout.PropertyField(_intensity);
  59. EditorGUILayout.PropertyField(_radius);
  60. EditorGUILayout.PropertyField(_highQuality);
  61. EditorGUILayout.PropertyField(_antiFlicker);
  62. serializedObject.ApplyModifiedProperties();
  63. }
  64. }
  65. }