源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
4.7 KiB

  1. using UnityEngine;
  2. using UnityEditor;
  3. [CustomEditor(typeof(PostEffect))]
  4. public class PostEffectEditor : Editor
  5. {
  6. PostEffect postEffect;
  7. bool first_loaded = true;
  8. BlurType temp_blurType = BlurType.Standard;
  9. public override void OnInspectorGUI()
  10. {
  11. postEffect = target as PostEffect;
  12. DoBloom();
  13. DoFXAA();
  14. DoBlurEffect();
  15. DoCheckMaterial();
  16. first_loaded = false;
  17. }
  18. void DoBloom()
  19. {
  20. GUILayout.Label("泛光相关参数", EditorStyles.boldLabel);
  21. postEffect.EnableBloom = EditorGUILayout.Toggle("Enable Bloom", postEffect.EnableBloom);
  22. postEffect.fastBloomShader = EditorGUILayout.ObjectField("Bloom Shader(Guassian)", postEffect.fastBloomShader, typeof(Shader), true) as Shader;
  23. postEffect.dualBloomShader = EditorGUILayout.ObjectField("Bloom Shader(Dual)", postEffect.dualBloomShader, typeof(Shader), true) as Shader;
  24. if(postEffect.EnableBloom && postEffect.fastBloomShader != null && postEffect.dualBloomShader != null)
  25. {
  26. postEffect.use_dual_bloom = EditorGUILayout.Toggle("Use Dual Bloom", postEffect.use_dual_bloom);
  27. postEffect.threshold = EditorGUILayout.Slider("Bloom Threshold", postEffect.threshold, 0f, 1.5f);
  28. postEffect.intensity = EditorGUILayout.Slider("Bloom Intensity", postEffect.intensity, 0f, 3f);
  29. postEffect.blurSize = EditorGUILayout.Slider("Bloom BlurSize", postEffect.blurSize, 0.25f, 5.5f);
  30. postEffect.blurIterations = EditorGUILayout.IntSlider("Bloom Iteration", postEffect.blurIterations, 1, 4);
  31. postEffect.blurType = (BlurType)EditorGUILayout.EnumPopup("Bloom BlurType", postEffect.blurType);
  32. if(temp_blurType != postEffect.blurType || first_loaded)
  33. {
  34. postEffect.ApplyBloomMaterialProperties();
  35. temp_blurType = postEffect.blurType;
  36. }
  37. if(GUILayout.Button("Apply Bloom Properties"))
  38. {
  39. postEffect.ApplyBloomMaterialProperties();
  40. }
  41. }
  42. GUILayout.Space(20);
  43. }
  44. void DoFXAA()
  45. {
  46. GUILayout.Label("FXAA抗锯齿相关参数", EditorStyles.boldLabel);
  47. postEffect.EnableFXAA = EditorGUILayout.Toggle("Enable FXAA", postEffect.EnableFXAA);
  48. postEffect.FXAAShader = EditorGUILayout.ObjectField("FXAA Shader", postEffect.FXAAShader, typeof(Shader), true) as Shader;
  49. if(postEffect.EnableFXAA && postEffect.FXAAShader != null)
  50. {
  51. postEffect.lowQuality = EditorGUILayout.Toggle("FXAA LowQuality", postEffect.lowQuality);
  52. postEffect.contrastThreshold = EditorGUILayout.Slider("FXAA ContrastThreshold", postEffect.contrastThreshold, 0.0312f, 0.0833f);
  53. postEffect.relativeThreshold = EditorGUILayout.Slider("FXAA RelativeThreshold", postEffect.relativeThreshold, 0.063f, 0.333f);
  54. postEffect.subpixelBlending = EditorGUILayout.Slider("FXAA RelativeThreshold", postEffect.subpixelBlending, 0f, 1f);
  55. if(GUILayout.Button("Apply FXAA Properties"))
  56. {
  57. postEffect.ApplyFXAAMaterialProperties();
  58. }
  59. }
  60. GUILayout.Space(20);
  61. }
  62. void DoBlurEffect()
  63. {
  64. GUILayout.Label("模糊后处理相关参数", EditorStyles.boldLabel);
  65. postEffect.EnableBlur = EditorGUILayout.Toggle("Enable Blur", postEffect.EnableBlur);
  66. postEffect.blurShader = EditorGUILayout.ObjectField("GuassianBlur Shader", postEffect.blurShader, typeof(Shader), true) as Shader;
  67. postEffect.dualBlurShader = EditorGUILayout.ObjectField("DualBlur Shader", postEffect.dualBlurShader, typeof(Shader), true) as Shader;
  68. if(postEffect.EnableBlur && postEffect.blurShader != null && postEffect.dualBlurShader != null)
  69. {
  70. postEffect.use_dual_blur = EditorGUILayout.Toggle("Use Dual Blur", postEffect.use_dual_blur);
  71. postEffect.render_blur_effect = EditorGUILayout.Toggle("Use Continues Blur", postEffect.render_blur_effect);
  72. // postEffect.get_screen_shot = EditorGUILayout.Toggle("Get Blur ScreenShot", postEffect.get_screen_shot);
  73. postEffect.blurSpread = EditorGUILayout.Slider("Blur Spread", postEffect.blurSpread, 0, 10f);
  74. postEffect.blur_amount = EditorGUILayout.Slider("Blur Amount", postEffect.blur_amount, 0, 1f);
  75. postEffect.recurveMaxNum = EditorGUILayout.IntSlider("Blur Iteration", postEffect.recurveMaxNum, 1, 10);
  76. postEffect.downSample = EditorGUILayout.IntSlider("Blur DownSample", postEffect.downSample, 1, 6);
  77. }
  78. GUILayout.Space(20);
  79. }
  80. void DoCheckMaterial()
  81. {
  82. if(GUILayout.Button("Check Material"))
  83. {
  84. postEffect.CheckResources();
  85. }
  86. }
  87. }