DirtyLensFlareEditor.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. [CustomEditor(typeof(DirtyLensFlare))]
  5. public class DirtyLensFlareEditor : Editor {
  6. SerializedObject serObj;
  7. SerializedProperty lensFlareType;
  8. SerializedProperty useDirt;
  9. SerializedProperty saturation;
  10. SerializedProperty flareIntensity;
  11. SerializedProperty bloomIntensity;
  12. SerializedProperty threshold;
  13. SerializedProperty blurSpread;
  14. SerializedProperty blurIterations;
  15. SerializedProperty dirtTexture;
  16. SerializedProperty downsample;
  17. GUIStyle style;
  18. void OnEnable()
  19. {
  20. serObj = new SerializedObject (target);
  21. lensFlareType = serObj.FindProperty("lensFlareType");
  22. useDirt = serObj.FindProperty("useDirt");
  23. saturation = serObj.FindProperty("saturation");
  24. flareIntensity = serObj.FindProperty("flareIntensity");
  25. bloomIntensity = serObj.FindProperty("bloomIntensity");
  26. threshold = serObj.FindProperty("threshold");
  27. blurIterations = serObj.FindProperty("iterations");
  28. blurSpread = serObj.FindProperty("blurSpread");
  29. downsample = serObj.FindProperty("downsample");
  30. dirtTexture = serObj.FindProperty("screenDirt");
  31. }
  32. public override void OnInspectorGUI () {
  33. serObj.Update();
  34. EditorGUILayout.PropertyField (lensFlareType, new GUIContent("Lens flare type"));
  35. threshold.floatValue = EditorGUILayout.Slider ("Threshold", threshold.floatValue, 0.0f, 1.0f);
  36. if( lensFlareType.enumValueIndex == 0 || lensFlareType.enumValueIndex == 2 )
  37. {
  38. saturation.floatValue = EditorGUILayout.Slider ("Flare saturation", saturation.floatValue, -2.0f, 2.0f);
  39. flareIntensity.floatValue = EditorGUILayout.Slider ("Flare intensity", flareIntensity.floatValue, 0.0f, 10.0f);
  40. if( lensFlareType.enumValueIndex == 0 )
  41. bloomIntensity.floatValue = EditorGUILayout.Slider ("Bloom intensity", bloomIntensity.floatValue, 0.0f, 10.0f);
  42. }
  43. else
  44. {
  45. bloomIntensity.floatValue = EditorGUILayout.Slider ("Bloom intensity", bloomIntensity.floatValue, 0.0f, 10.0f);
  46. }
  47. EditorGUILayout.Separator ();
  48. blurSpread.floatValue = EditorGUILayout.Slider ("Blur spread", blurSpread.floatValue, 0.0f, 2.0f);
  49. blurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", blurIterations.intValue, 0, 64);
  50. EditorGUILayout.Separator ();
  51. downsample.intValue = EditorGUILayout.IntField("Downsample", downsample.intValue);
  52. downsample.intValue = Mathf.Clamp(downsample.intValue, 1, 12);
  53. EditorGUILayout.Separator ();
  54. EditorGUILayout.PropertyField (useDirt, new GUIContent("Use dirt"));
  55. EditorGUILayout.PropertyField (dirtTexture, new GUIContent("Screen dirt texture"));
  56. serObj.ApplyModifiedProperties();
  57. }
  58. }