DepthOfFieldDeprecatedEditor.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace UnityStandardAssets.ImageEffects
  5. {
  6. [CustomEditor (typeof(DepthOfFieldDeprecated))]
  7. class DepthOfFieldDeprecatedEditor : Editor
  8. {
  9. SerializedObject serObj;
  10. SerializedProperty simpleTweakMode;
  11. SerializedProperty focalPoint;
  12. SerializedProperty smoothness;
  13. SerializedProperty focalSize;
  14. SerializedProperty focalZDistance;
  15. SerializedProperty focalStartCurve;
  16. SerializedProperty focalEndCurve;
  17. SerializedProperty visualizeCoc;
  18. SerializedProperty resolution;
  19. SerializedProperty quality;
  20. SerializedProperty objectFocus;
  21. SerializedProperty bokeh;
  22. SerializedProperty bokehScale;
  23. SerializedProperty bokehIntensity;
  24. SerializedProperty bokehThresholdLuminance;
  25. SerializedProperty bokehThresholdContrast;
  26. SerializedProperty bokehDownsample;
  27. SerializedProperty bokehTexture;
  28. SerializedProperty bokehDestination;
  29. SerializedProperty bluriness;
  30. SerializedProperty maxBlurSpread;
  31. SerializedProperty foregroundBlurExtrude;
  32. void OnEnable () {
  33. serObj = new SerializedObject (target);
  34. simpleTweakMode = serObj.FindProperty ("simpleTweakMode");
  35. // simple tweak mode
  36. focalPoint = serObj.FindProperty ("focalPoint");
  37. smoothness = serObj.FindProperty ("smoothness");
  38. // complex tweak mode
  39. focalZDistance = serObj.FindProperty ("focalZDistance");
  40. focalStartCurve = serObj.FindProperty ("focalZStartCurve");
  41. focalEndCurve = serObj.FindProperty ("focalZEndCurve");
  42. focalSize = serObj.FindProperty ("focalSize");
  43. visualizeCoc = serObj.FindProperty ("visualize");
  44. objectFocus = serObj.FindProperty ("objectFocus");
  45. resolution = serObj.FindProperty ("resolution");
  46. quality = serObj.FindProperty ("quality");
  47. bokehThresholdContrast = serObj.FindProperty ("bokehThresholdContrast");
  48. bokehThresholdLuminance = serObj.FindProperty ("bokehThresholdLuminance");
  49. bokeh = serObj.FindProperty ("bokeh");
  50. bokehScale = serObj.FindProperty ("bokehScale");
  51. bokehIntensity = serObj.FindProperty ("bokehIntensity");
  52. bokehDownsample = serObj.FindProperty ("bokehDownsample");
  53. bokehTexture = serObj.FindProperty ("bokehTexture");
  54. bokehDestination = serObj.FindProperty ("bokehDestination");
  55. bluriness = serObj.FindProperty ("bluriness");
  56. maxBlurSpread = serObj.FindProperty ("maxBlurSpread");
  57. foregroundBlurExtrude = serObj.FindProperty ("foregroundBlurExtrude");
  58. }
  59. public override void OnInspectorGUI () {
  60. serObj.Update ();
  61. GameObject go = (target as DepthOfFieldDeprecated).gameObject;
  62. if (!go)
  63. return;
  64. if (!go.GetComponent<Camera>())
  65. return;
  66. if (simpleTweakMode.boolValue)
  67. GUILayout.Label ("Current: "+go.GetComponent<Camera>().name+", near "+go.GetComponent<Camera>().nearClipPlane+", far: "+go.GetComponent<Camera>().farClipPlane+", focal: "+focalPoint.floatValue, EditorStyles.miniBoldLabel);
  68. else
  69. GUILayout.Label ("Current: "+go.GetComponent<Camera>().name+", near "+go.GetComponent<Camera>().nearClipPlane+", far: "+go.GetComponent<Camera>().farClipPlane+", focal: "+focalZDistance.floatValue, EditorStyles.miniBoldLabel);
  70. EditorGUILayout.PropertyField (resolution, new GUIContent("Resolution"));
  71. EditorGUILayout.PropertyField (quality, new GUIContent("Quality"));
  72. EditorGUILayout.PropertyField (simpleTweakMode, new GUIContent("Simple tweak"));
  73. EditorGUILayout.PropertyField (visualizeCoc, new GUIContent("Visualize focus"));
  74. EditorGUILayout.PropertyField (bokeh, new GUIContent("Enable bokeh"));
  75. EditorGUILayout.Separator ();
  76. GUILayout.Label ("Focal Settings", EditorStyles.boldLabel);
  77. if (simpleTweakMode.boolValue) {
  78. focalPoint.floatValue = EditorGUILayout.Slider ("Focal distance", focalPoint.floatValue, go.GetComponent<Camera>().nearClipPlane, go.GetComponent<Camera>().farClipPlane);
  79. EditorGUILayout.PropertyField (objectFocus, new GUIContent("Transform"));
  80. EditorGUILayout.PropertyField (smoothness, new GUIContent("Smoothness"));
  81. focalSize.floatValue = EditorGUILayout.Slider ("Focal size", focalSize.floatValue, 0.0f, (go.GetComponent<Camera>().farClipPlane - go.GetComponent<Camera>().nearClipPlane));
  82. }
  83. else {
  84. focalZDistance.floatValue = EditorGUILayout.Slider ("Distance", focalZDistance.floatValue, go.GetComponent<Camera>().nearClipPlane, go.GetComponent<Camera>().farClipPlane);
  85. EditorGUILayout.PropertyField (objectFocus, new GUIContent("Transform"));
  86. focalSize.floatValue = EditorGUILayout.Slider ("Size", focalSize.floatValue, 0.0f, (go.GetComponent<Camera>().farClipPlane - go.GetComponent<Camera>().nearClipPlane));
  87. focalStartCurve.floatValue = EditorGUILayout.Slider ("Start curve", focalStartCurve.floatValue, 0.05f, 20.0f);
  88. focalEndCurve.floatValue = EditorGUILayout.Slider ("End curve", focalEndCurve.floatValue, 0.05f, 20.0f);
  89. }
  90. EditorGUILayout.Separator ();
  91. GUILayout.Label ("Blur (Fore- and Background)", EditorStyles.boldLabel);
  92. EditorGUILayout.PropertyField (bluriness, new GUIContent("Blurriness"));
  93. EditorGUILayout.PropertyField (maxBlurSpread, new GUIContent("Blur spread"));
  94. if (quality.enumValueIndex > 0) {
  95. EditorGUILayout.PropertyField (foregroundBlurExtrude, new GUIContent("Foreground size"));
  96. }
  97. EditorGUILayout.Separator ();
  98. if (bokeh.boolValue) {
  99. EditorGUILayout.Separator ();
  100. GUILayout.Label ("Bokeh Settings", EditorStyles.boldLabel);
  101. EditorGUILayout.PropertyField (bokehDestination, new GUIContent("Destination"));
  102. bokehIntensity.floatValue = EditorGUILayout.Slider ("Intensity", bokehIntensity.floatValue, 0.0f, 1.0f);
  103. bokehThresholdLuminance.floatValue = EditorGUILayout.Slider ("Min luminance", bokehThresholdLuminance.floatValue, 0.0f, 0.99f);
  104. bokehThresholdContrast.floatValue = EditorGUILayout.Slider ("Min contrast", bokehThresholdContrast.floatValue, 0.0f, 0.25f);
  105. bokehDownsample.intValue = EditorGUILayout.IntSlider ("Downsample", bokehDownsample.intValue, 1, 3);
  106. bokehScale.floatValue = EditorGUILayout.Slider ("Size scale", bokehScale.floatValue, 0.0f, 20.0f);
  107. EditorGUILayout.PropertyField (bokehTexture , new GUIContent("Texture mask"));
  108. }
  109. serObj.ApplyModifiedProperties();
  110. }
  111. }
  112. }