VignetteAndChromaticAberrationEditor.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace UnityStandardAssets.ImageEffects
  5. {
  6. [CustomEditor (typeof(VignetteAndChromaticAberration))]
  7. class VignetteAndChromaticAberrationEditor : Editor
  8. {
  9. private SerializedObject m_SerObj;
  10. private SerializedProperty m_Mode;
  11. private SerializedProperty m_Intensity; // intensity == 0 disables pre pass (optimization)
  12. private SerializedProperty m_ChromaticAberration;
  13. private SerializedProperty m_AxialAberration;
  14. private SerializedProperty m_Blur; // blur == 0 disables blur pass (optimization)
  15. private SerializedProperty m_BlurSpread;
  16. private SerializedProperty m_BlurDistance;
  17. private SerializedProperty m_LuminanceDependency;
  18. void OnEnable ()
  19. {
  20. m_SerObj = new SerializedObject (target);
  21. m_Mode = m_SerObj.FindProperty ("mode");
  22. m_Intensity = m_SerObj.FindProperty ("intensity");
  23. m_ChromaticAberration = m_SerObj.FindProperty ("chromaticAberration");
  24. m_AxialAberration = m_SerObj.FindProperty ("axialAberration");
  25. m_Blur = m_SerObj.FindProperty ("blur");
  26. m_BlurSpread = m_SerObj.FindProperty ("blurSpread");
  27. m_LuminanceDependency = m_SerObj.FindProperty ("luminanceDependency");
  28. m_BlurDistance = m_SerObj.FindProperty ("blurDistance");
  29. }
  30. public override void OnInspectorGUI ()
  31. {
  32. m_SerObj.Update ();
  33. EditorGUILayout.LabelField("Simulates the common lens artifacts 'Vignette' and 'Aberration'", EditorStyles.miniLabel);
  34. EditorGUILayout.Slider(m_Intensity, 0.0f, 1.0f, new GUIContent("Vignetting"));
  35. EditorGUILayout.Slider(m_Blur, 0.0f, 1.0f, new GUIContent(" Blurred Corners"));
  36. if (m_Blur.floatValue>0.0f)
  37. EditorGUILayout.Slider(m_BlurSpread, 0.0f, 1.0f, new GUIContent(" Blur Distance"));
  38. EditorGUILayout.Separator ();
  39. EditorGUILayout.PropertyField (m_Mode, new GUIContent("Aberration"));
  40. if (m_Mode.intValue>0)
  41. {
  42. EditorGUILayout.Slider(m_ChromaticAberration, 0.0f, 5.0f, new GUIContent(" Tangential Aberration"));
  43. EditorGUILayout.Slider(m_AxialAberration, 0.0f, 5.0f, new GUIContent(" Axial Aberration"));
  44. m_LuminanceDependency.floatValue = EditorGUILayout.Slider(" Contrast Dependency", m_LuminanceDependency.floatValue, 0.001f, 1.0f);
  45. m_BlurDistance.floatValue = EditorGUILayout.Slider(" Blur Distance", m_BlurDistance.floatValue, 0.001f, 5.0f);
  46. }
  47. else
  48. EditorGUILayout.PropertyField (m_ChromaticAberration, new GUIContent(" Chromatic Aberration"));
  49. m_SerObj.ApplyModifiedProperties();
  50. }
  51. }
  52. }