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.

URPBuildDataValidator.cs 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEditor.Build.Reporting;
  5. using UnityEngine.Rendering;
  6. using UnityEngine.Rendering.Universal;
  7. namespace UnityEditor.Rendering.Universal
  8. {
  9. class URPBuildDataValidator
  10. {
  11. private static void ValidateRenderPipelineAssetsAreAtLastVersion(List<UniversalRenderPipelineAsset> renderPipelineAssets, StringBuilder failures)
  12. {
  13. // Validate all included assets are at last version
  14. foreach (var urpPipelineAsset in renderPipelineAssets)
  15. {
  16. if (!urpPipelineAsset.IsAtLastVersion())
  17. {
  18. failures.AppendLine(
  19. $"- The {nameof(UniversalRenderPipelineAsset)} with '{urpPipelineAsset.name}({AssetDatabase.GetAssetPath(urpPipelineAsset)})' is not at last version.");
  20. }
  21. }
  22. }
  23. private static void ValidateRenderPipelineGlobalSettings(UniversalRenderPipelineGlobalSettings globalSettingsInstance, StringBuilder failures)
  24. {
  25. if (globalSettingsInstance == null)
  26. failures.AppendLine($"- The {nameof(UniversalRenderPipelineGlobalSettings)} of the project are missing.");
  27. else
  28. {
  29. if (!globalSettingsInstance.IsAtLastVersion())
  30. {
  31. failures.AppendLine(
  32. $"- The {nameof(UniversalRenderPipelineGlobalSettings)} with '{globalSettingsInstance.name}({AssetDatabase.GetAssetPath(globalSettingsInstance)})' is not at last version.");
  33. }
  34. }
  35. }
  36. public static bool IsProjectValidForBuilding(BuildReport report, out string message)
  37. {
  38. using (GenericPool<StringBuilder>.Get(out var failures))
  39. {
  40. failures.Clear();
  41. ValidateRenderPipelineAssetsAreAtLastVersion(URPBuildData.instance.renderPipelineAssets, failures);
  42. ValidateRenderPipelineGlobalSettings(UniversalRenderPipelineGlobalSettings.Ensure(), failures);
  43. string allFailures = failures.ToString();
  44. if (!string.IsNullOrEmpty(allFailures))
  45. {
  46. message =
  47. $"Please fix the following errors before building:{Environment.NewLine}{allFailures}. {Environment.NewLine}";
  48. return false;
  49. }
  50. }
  51. message = string.Empty;
  52. return true;
  53. }
  54. }
  55. }