AntialiasingEditor.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace UnityStandardAssets.ImageEffects
  5. {
  6. [CustomEditor(typeof (Antialiasing))]
  7. public class AntialiasingEditor : Editor
  8. {
  9. private SerializedObject serObj;
  10. private SerializedProperty mode;
  11. private SerializedProperty showGeneratedNormals;
  12. private SerializedProperty offsetScale;
  13. private SerializedProperty blurRadius;
  14. private SerializedProperty dlaaSharp;
  15. private SerializedProperty edgeThresholdMin;
  16. private SerializedProperty edgeThreshold;
  17. private SerializedProperty edgeSharpness;
  18. private void OnEnable()
  19. {
  20. serObj = new SerializedObject(target);
  21. mode = serObj.FindProperty("mode");
  22. showGeneratedNormals = serObj.FindProperty("showGeneratedNormals");
  23. offsetScale = serObj.FindProperty("offsetScale");
  24. blurRadius = serObj.FindProperty("blurRadius");
  25. dlaaSharp = serObj.FindProperty("dlaaSharp");
  26. edgeThresholdMin = serObj.FindProperty("edgeThresholdMin");
  27. edgeThreshold = serObj.FindProperty("edgeThreshold");
  28. edgeSharpness = serObj.FindProperty("edgeSharpness");
  29. }
  30. public override void OnInspectorGUI()
  31. {
  32. serObj.Update();
  33. GUILayout.Label("Luminance based fullscreen antialiasing", EditorStyles.miniBoldLabel);
  34. EditorGUILayout.PropertyField(mode, new GUIContent("Technique"));
  35. Material mat = (target as Antialiasing).CurrentAAMaterial();
  36. if (null == mat && (target as Antialiasing).enabled)
  37. {
  38. EditorGUILayout.HelpBox("This AA technique is currently not supported. Choose a different technique or disable the effect and use MSAA instead.", MessageType.Warning);
  39. }
  40. if (mode.enumValueIndex == (int) AAMode.NFAA)
  41. {
  42. EditorGUILayout.PropertyField(offsetScale, new GUIContent("Edge Detect Ofs"));
  43. EditorGUILayout.PropertyField(blurRadius, new GUIContent("Blur Radius"));
  44. EditorGUILayout.PropertyField(showGeneratedNormals, new GUIContent("Show Normals"));
  45. }
  46. else if (mode.enumValueIndex == (int) AAMode.DLAA)
  47. {
  48. EditorGUILayout.PropertyField(dlaaSharp, new GUIContent("Sharp"));
  49. }
  50. else if (mode.enumValueIndex == (int) AAMode.FXAA3Console)
  51. {
  52. EditorGUILayout.PropertyField(edgeThresholdMin, new GUIContent("Edge Min Threshhold"));
  53. EditorGUILayout.PropertyField(edgeThreshold, new GUIContent("Edge Threshhold"));
  54. EditorGUILayout.PropertyField(edgeSharpness, new GUIContent("Edge Sharpness"));
  55. }
  56. serObj.ApplyModifiedProperties();
  57. }
  58. }
  59. }