No Description
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.

URPProcessScene.cs 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEditor.Build;
  2. using UnityEditor.Build.Reporting;
  3. using UnityEngine;
  4. using UnityEngine.Rendering;
  5. using UnityEngine.Rendering.Universal;
  6. namespace UnityEditor.Rendering.Universal
  7. {
  8. class URPProcessScene : IProcessSceneWithReport
  9. {
  10. public int callbackOrder => 0;
  11. public void OnProcessScene(UnityEngine.SceneManagement.Scene scene, BuildReport report)
  12. {
  13. bool usesURP = false;
  14. if (GraphicsSettings.defaultRenderPipeline as UniversalRenderPipelineAsset != null)
  15. {
  16. // ^ The global pipeline is set to URP
  17. usesURP = true;
  18. }
  19. else
  20. {
  21. // ^ The global pipeline isn't set to URP, but a quality setting could still use it
  22. for (int i = 0; i < QualitySettings.count; i++)
  23. {
  24. if (QualitySettings.GetRenderPipelineAssetAt(i) as UniversalRenderPipelineAsset != null)
  25. {
  26. // ^ This quality setting uses URP
  27. usesURP = true;
  28. break;
  29. }
  30. }
  31. }
  32. if (usesURP)
  33. {
  34. GameObject[] roots = scene.GetRootGameObjects();
  35. foreach (GameObject root in roots)
  36. {
  37. Light[] lights = root.GetComponentsInChildren<Light>();
  38. foreach (Light light in lights)
  39. {
  40. if (light.type != LightType.Directional &&
  41. light.type != LightType.Point &&
  42. light.type != LightType.Spot &&
  43. light.type != LightType.Rectangle)
  44. {
  45. Debug.LogWarning(
  46. $"The {light.type} light type on the GameObject '{light.gameObject.name}' is unsupported by URP, and will not be rendered."
  47. );
  48. }
  49. else if (light.type == LightType.Rectangle && light.lightmapBakeType != LightmapBakeType.Baked)
  50. {
  51. Debug.LogWarning(
  52. $"The GameObject '{light.gameObject.name}' is an area light type, but the mode is not set to baked. URP only supports baked area lights, not realtime or mixed ones."
  53. );
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }