Ingen beskrivning
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.

RenderPipelineGlobalSettings.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. #if UNITY_EDITOR
  3. using UnityEditor.Rendering;
  4. #endif
  5. namespace UnityEngine.Rendering
  6. {
  7. /// <summary>
  8. /// A <see cref="ScriptableObject"/> to associate with a <see cref="RenderPipeline"/> and store project-wide settings for that pipeline.
  9. /// You can register a single <see cref="RenderPipelineGlobalSettings"/> instance to the <see cref="GraphicsSettings"/> by using <see cref="Rendering.GraphicsSettings.RegisterRenderPipelineSettings"/>. You can use this to save `RenderPipeline` settings that appear in `GraphicsSettings`.
  10. /// </summary>
  11. /// <typeparam name="TGlobalRenderPipelineSettings"><see cref="RenderPipelineGlobalSettings"/></typeparam>
  12. /// <typeparam name="TRenderPipeline"><see cref="RenderPipeline"/></typeparam>
  13. public abstract class RenderPipelineGlobalSettings<TGlobalRenderPipelineSettings, TRenderPipeline> : RenderPipelineGlobalSettings
  14. where TRenderPipeline : RenderPipeline
  15. where TGlobalRenderPipelineSettings : RenderPipelineGlobalSettings
  16. {
  17. /// <summary>
  18. /// Active Global Settings asset. If the value is `null` then no `TGlobalRenderPipelineSettings` is registered to the Graphics Settings with the `TRenderPipeline`.
  19. /// </summary>
  20. #if UNITY_EDITOR
  21. public static TGlobalRenderPipelineSettings instance =>
  22. EditorGraphicsSettings.GetRenderPipelineGlobalSettingsAsset<TRenderPipeline>() as TGlobalRenderPipelineSettings;
  23. #else
  24. public static TGlobalRenderPipelineSettings instance => s_Instance.Value;
  25. private static Lazy<TGlobalRenderPipelineSettings> s_Instance = new (() => GraphicsSettings.GetSettingsForRenderPipeline<TRenderPipeline>() as TGlobalRenderPipelineSettings);
  26. #endif
  27. /// <summary>
  28. /// Called when settings asset is reset in the editor.
  29. /// </summary>
  30. public virtual void Reset()
  31. {
  32. #if UNITY_EDITOR
  33. EditorGraphicsSettings.PopulateRenderPipelineGraphicsSettings(this);
  34. Initialize();
  35. #endif
  36. }
  37. }
  38. }