CameraMotionBlurEditor.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace UnityStandardAssets.ImageEffects
  5. {
  6. [CustomEditor (typeof(CameraMotionBlur))]
  7. class CameraMotionBlurEditor : Editor
  8. {
  9. SerializedObject serObj;
  10. SerializedProperty filterType;
  11. SerializedProperty preview;
  12. SerializedProperty previewScale;
  13. SerializedProperty movementScale;
  14. SerializedProperty jitter;
  15. SerializedProperty rotationScale;
  16. SerializedProperty maxVelocity;
  17. SerializedProperty minVelocity;
  18. SerializedProperty velocityScale;
  19. SerializedProperty velocityDownsample;
  20. SerializedProperty noiseTexture;
  21. SerializedProperty showVelocity;
  22. SerializedProperty showVelocityScale;
  23. SerializedProperty excludeLayers;
  24. void OnEnable () {
  25. serObj = new SerializedObject (target);
  26. filterType = serObj.FindProperty ("filterType");
  27. preview = serObj.FindProperty ("preview");
  28. previewScale = serObj.FindProperty ("previewScale");
  29. movementScale = serObj.FindProperty ("movementScale");
  30. rotationScale = serObj.FindProperty ("rotationScale");
  31. maxVelocity = serObj.FindProperty ("maxVelocity");
  32. minVelocity = serObj.FindProperty ("minVelocity");
  33. jitter = serObj.FindProperty ("jitter");
  34. excludeLayers = serObj.FindProperty ("excludeLayers");
  35. velocityScale = serObj.FindProperty ("velocityScale");
  36. velocityDownsample = serObj.FindProperty ("velocityDownsample");
  37. noiseTexture = serObj.FindProperty ("noiseTexture");
  38. }
  39. public override void OnInspectorGUI () {
  40. serObj.Update ();
  41. EditorGUILayout.LabelField("Simulates camera based motion blur", EditorStyles.miniLabel);
  42. EditorGUILayout.PropertyField (filterType, new GUIContent("Technique"));
  43. if (filterType.enumValueIndex == 3 && !(target as CameraMotionBlur).Dx11Support()) {
  44. EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info);
  45. }
  46. EditorGUILayout.PropertyField (velocityScale, new GUIContent(" Velocity Scale"));
  47. if (filterType.enumValueIndex >= 2) {
  48. EditorGUILayout.LabelField(" Tile size used during reconstruction filter:", EditorStyles.miniLabel);
  49. EditorGUILayout.Slider(maxVelocity, 2.0f, 10.0f, new GUIContent(" Velocity Max"));
  50. }
  51. else
  52. EditorGUILayout.Slider (maxVelocity, 2.0f, 10.0f, new GUIContent(" Velocity Max"));
  53. EditorGUILayout.Slider(minVelocity, 0.0f, 10.0f, new GUIContent(" Velocity Min"));
  54. EditorGUILayout.Separator ();
  55. EditorGUILayout.LabelField("Technique Specific");
  56. if (filterType.enumValueIndex == 0) {
  57. // portal style motion blur
  58. EditorGUILayout.PropertyField (rotationScale, new GUIContent(" Camera Rotation"));
  59. EditorGUILayout.PropertyField (movementScale, new GUIContent(" Camera Movement"));
  60. }
  61. else {
  62. // "plausible" blur or cheap, local blur
  63. EditorGUILayout.PropertyField (excludeLayers, new GUIContent(" Exclude Layers"));
  64. EditorGUILayout.PropertyField (velocityDownsample, new GUIContent(" Velocity Downsample"));
  65. velocityDownsample.intValue = velocityDownsample.intValue < 1 ? 1 : velocityDownsample.intValue;
  66. if (filterType.enumValueIndex >= 2) { // only display jitter for reconstruction
  67. EditorGUILayout.PropertyField (noiseTexture, new GUIContent(" Sample Jitter"));
  68. EditorGUILayout.Slider (jitter, 0.0f, 10.0f, new GUIContent(" Jitter Strength"));
  69. }
  70. }
  71. EditorGUILayout.Separator ();
  72. EditorGUILayout.PropertyField (preview, new GUIContent("Preview"));
  73. if (preview.boolValue)
  74. EditorGUILayout.PropertyField (previewScale, new GUIContent(""));
  75. serObj.ApplyModifiedProperties();
  76. }
  77. }
  78. }