BloomAndFlaresEditor.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. @script ExecuteInEditMode()
  2. @CustomEditor (BloomAndFlares)
  3. class BloomAndFlaresEditor extends Editor
  4. {
  5. var tweakMode : SerializedProperty;
  6. var serObj : SerializedObject;
  7. var bloomThisTag : SerializedProperty;
  8. var sepBlurSpread : SerializedProperty;
  9. var useSrcAlphaAsMask : SerializedProperty;
  10. var bloomIntensity : SerializedProperty;
  11. var bloomThreshhold : SerializedProperty;
  12. var bloomBlurIterations : SerializedProperty;
  13. var lensflares : SerializedProperty;
  14. var hollywoodFlareBlurIterations : SerializedProperty;
  15. var lensflareMode : SerializedProperty;
  16. var hollyStretchWidth : SerializedProperty;
  17. var lensflareIntensity : SerializedProperty;
  18. var lensflareThreshhold : SerializedProperty;
  19. var flareColorA : SerializedProperty;
  20. var flareColorB : SerializedProperty;
  21. var flareColorC : SerializedProperty;
  22. var flareColorD : SerializedProperty;
  23. var blurWidth : SerializedProperty;
  24. function OnEnable () {
  25. serObj = new SerializedObject (target);
  26. bloomThisTag = serObj.FindProperty("bloomThisTag");
  27. sepBlurSpread = serObj.FindProperty("sepBlurSpread");
  28. useSrcAlphaAsMask = serObj.FindProperty("useSrcAlphaAsMask");
  29. bloomIntensity = serObj.FindProperty("bloomIntensity");
  30. bloomThreshhold = serObj.FindProperty("bloomThreshhold");
  31. bloomBlurIterations = serObj.FindProperty("bloomBlurIterations");
  32. lensflares = serObj.FindProperty("lensflares");
  33. lensflareMode = serObj.FindProperty("lensflareMode");
  34. hollywoodFlareBlurIterations = serObj.FindProperty("hollywoodFlareBlurIterations");
  35. hollyStretchWidth = serObj.FindProperty("hollyStretchWidth");
  36. lensflareIntensity = serObj.FindProperty("lensflareIntensity");
  37. lensflareThreshhold = serObj.FindProperty("lensflareThreshhold");
  38. flareColorA = serObj.FindProperty("flareColorA");
  39. flareColorB = serObj.FindProperty("flareColorB");
  40. flareColorC = serObj.FindProperty("flareColorC");
  41. flareColorD = serObj.FindProperty("flareColorD");
  42. blurWidth = serObj.FindProperty("blurWidth");
  43. tweakMode = serObj.FindProperty("tweakMode");
  44. }
  45. function OnInspectorGUI ()
  46. {
  47. serObj.Update();
  48. //tweakMode = EditorGUILayout.EnumPopup("Mode", tweakMode, EditorStyles.popup);
  49. EditorGUILayout.PropertyField (tweakMode, new GUIContent("Mode"));
  50. EditorGUILayout.Separator ();
  51. // some genral tweak needs
  52. EditorGUILayout.PropertyField (bloomIntensity, new GUIContent("Intensity"));
  53. EditorGUILayout.Separator ();
  54. bloomBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", bloomBlurIterations.intValue, 1, 10);
  55. if(1==tweakMode.intValue)
  56. sepBlurSpread.floatValue = EditorGUILayout.Slider ("Blur spread", sepBlurSpread.floatValue, 0.1, 2.0);
  57. else
  58. sepBlurSpread.floatValue = 1.0;
  59. bloomThreshhold.floatValue = EditorGUILayout.Slider ("Threshhold", bloomThreshhold.floatValue, -0.05, 1.0);
  60. if(1==tweakMode.intValue)
  61. useSrcAlphaAsMask.floatValue = EditorGUILayout.Slider (new GUIContent("Use alpha mask","How much should the image alpha values (deifned by all materials, colors and textures alpha values define the bright (blooming/glowing) areas of the image"), useSrcAlphaAsMask.floatValue, 0.0, 1.0);
  62. else
  63. useSrcAlphaAsMask.floatValue = 1.0;
  64. EditorGUILayout.Separator ();
  65. EditorGUILayout.PropertyField (lensflares, new GUIContent("Cast lens flares"));
  66. if(lensflares.boolValue) {
  67. EditorGUILayout.PropertyField (lensflareIntensity, new GUIContent("Intensity"));
  68. lensflareThreshhold.floatValue = EditorGUILayout.Slider ("Threshhold", lensflareThreshhold.floatValue, 0.0, 1.0);
  69. EditorGUILayout.Separator ();
  70. // further lens flare tweakings
  71. EditorGUILayout.PropertyField (lensflareMode, new GUIContent(" Mode"));
  72. if (lensflareMode.intValue == 0) {
  73. // ghosting
  74. EditorGUILayout.PropertyField (flareColorA, new GUIContent(" Color"));
  75. EditorGUILayout.PropertyField (flareColorB, new GUIContent(" Color"));
  76. EditorGUILayout.PropertyField (flareColorC, new GUIContent(" Color"));
  77. EditorGUILayout.PropertyField (flareColorD, new GUIContent(" Color"));
  78. } else if (lensflareMode.intValue == 1) {
  79. // hollywood
  80. EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent(" Stretch width"));
  81. hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (" Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 8);
  82. EditorGUILayout.PropertyField (flareColorA, new GUIContent(" Color"));
  83. } else if (lensflareMode.intValue == 2) {
  84. // both
  85. EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent(" Stretch width"));
  86. hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (" Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 8);
  87. EditorGUILayout.PropertyField (flareColorA, new GUIContent(" Color"));
  88. EditorGUILayout.PropertyField (flareColorB, new GUIContent(" Color"));
  89. EditorGUILayout.PropertyField (flareColorC, new GUIContent(" Color"));
  90. EditorGUILayout.PropertyField (flareColorD, new GUIContent(" Color"));
  91. }
  92. }
  93. EditorGUILayout.Separator ();
  94. if (1==tweakMode.intValue)
  95. {
  96. //EditorGUILayout.PropertyField (bloomThisTag, new GUIContent("Extra Bloom Tag","If you want to always have objects of a certain tag to be 'glowing', select the tag here and tag the game objects in question. These objects will start glowing/blooming no matter what their material writes to the alpha channel."));
  97. GUILayout.Label("Add extra bloom on tagged objects?");
  98. EditorGUILayout.BeginHorizontal();
  99. GUILayout.Label(" Tag");
  100. bloomThisTag.stringValue = EditorGUILayout.TagField(bloomThisTag.stringValue);
  101. EditorGUILayout.EndHorizontal();
  102. EditorGUILayout.Separator ();
  103. }
  104. serObj.ApplyModifiedProperties();
  105. /*
  106. if (GUI.changed) {
  107. EditorUtility.SetDirty (target);
  108. //(target._dirty = true;
  109. }
  110. */
  111. }
  112. }