SceneViewDrawMode.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if UNITY_EDITOR
  2. using System.Collections;
  3. namespace UnityEditor.Rendering.Universal
  4. {
  5. internal static class SceneViewDrawMode
  6. {
  7. static bool RejectDrawMode(SceneView.CameraMode cameraMode)
  8. {
  9. if (cameraMode.drawMode == DrawCameraMode.TexturedWire ||
  10. cameraMode.drawMode == DrawCameraMode.ShadowCascades ||
  11. cameraMode.drawMode == DrawCameraMode.RenderPaths ||
  12. cameraMode.drawMode == DrawCameraMode.AlphaChannel ||
  13. cameraMode.drawMode == DrawCameraMode.Overdraw ||
  14. cameraMode.drawMode == DrawCameraMode.Mipmaps ||
  15. cameraMode.drawMode == DrawCameraMode.SpriteMask ||
  16. cameraMode.drawMode == DrawCameraMode.DeferredDiffuse ||
  17. cameraMode.drawMode == DrawCameraMode.DeferredSpecular ||
  18. cameraMode.drawMode == DrawCameraMode.DeferredSmoothness ||
  19. cameraMode.drawMode == DrawCameraMode.DeferredNormal ||
  20. cameraMode.drawMode == DrawCameraMode.ValidateAlbedo ||
  21. cameraMode.drawMode == DrawCameraMode.ValidateMetalSpecular ||
  22. cameraMode.drawMode == DrawCameraMode.ShadowMasks ||
  23. cameraMode.drawMode == DrawCameraMode.LightOverlap
  24. )
  25. return false;
  26. return true;
  27. }
  28. public static void SetupDrawMode()
  29. {
  30. ArrayList sceneViewArray = SceneView.sceneViews;
  31. foreach (SceneView sceneView in sceneViewArray)
  32. sceneView.onValidateCameraMode += RejectDrawMode;
  33. }
  34. public static void ResetDrawMode()
  35. {
  36. ArrayList sceneViewArray = SceneView.sceneViews;
  37. foreach (SceneView sceneView in sceneViewArray)
  38. sceneView.onValidateCameraMode -= RejectDrawMode;
  39. }
  40. }
  41. }
  42. #endif