This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,71 @@
using System;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build;
#endif
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A graphics settings container for settings related to Render Graph for <see cref="UniversalRenderPipeline"/>.
/// </summary>
/// <remarks>
/// To change those settings, go to Editor > Project Settings in the Graphics tab (URP).
/// Changing this through the API is only allowed in the Editor. In the Player, this raises an error.
/// </remarks>
/// <seealso cref="IRenderPipelineGraphicsSettings"/>
/// <example>
/// <para> This example demonstrates how to determine whether your project uses RenderGraph in URP. </para>
/// <code>
/// using UnityEngine.Rendering;
/// using UnityEngine.Rendering.Universal;
///
/// public static class URPRenderGraphHelper
/// {
/// public static bool enabled
/// {
/// get
/// {
/// var gs = GraphicsSettings.GetRenderPipelineSettings&lt;RenderGraphSettings&gt;();
/// if (gs == null) //not in URP
/// return false;
/// return !gs.enableRenderCompatibilityMode;
/// }
/// }
/// }
/// </code>
/// </example>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Render Graph", Order = 50)]
[Categorization.ElementInfo(Order = -10)]
[Obsolete("These settings are not used. #from(6000.4)", false)]
public class RenderGraphSettings : IRenderPipelineGraphicsSettings
{
#region Version
internal enum Version : int
{
Initial = 0,
}
[SerializeField][HideInInspector]
private Version m_Version;
/// <summary>Current version of the settings container. Used only for upgrading a project.</summary>
public int version => (int)m_Version;
#endregion
bool IRenderPipelineGraphicsSettings.isAvailableInPlayerBuild => false;
#region Data Accessors
/// <summary>
/// When enabled, Universal Rendering Pipeline will not use Render Graph API to construct and execute the frame.
/// </summary>
[Obsolete("This property is not used. #from(6000.4)", false)]
public bool enableRenderCompatibilityMode => false;
#endregion
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0cf625ee415e13145960c2d843523d39
@@ -0,0 +1,146 @@
using System;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Rendering;
#endif
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A Graphics Settings container for the default <see cref="VolumeProfile"/> used by <see cref="UniversalRenderPipeline"/>.
/// </summary>
/// <remarks>
/// To change those settings, go to Editor > Project Settings in the Graphics tab (URP).
/// Changing this through the API is only allowed in the Editor. In the Player, this raises an error.
/// </remarks>
/// <seealso cref="IRenderPipelineGraphicsSettings"/>
/// <example>
/// <para> This example demonstrates how to get the default volume profile used by URP. </para>
/// <code>
/// using UnityEngine.Rendering;
/// using UnityEngine.Rendering.Universal;
///
/// public static class URPDefaultVolumeProfileHelper
/// {
/// public static VolumeProfile volumeProfile
/// {
/// get
/// {
/// var gs = GraphicsSettings.GetRenderPipelineSettings&lt;URPDefaultVolumeProfileSettings&gt;();
/// if (gs == null) //not in URP
/// return null;
/// return gs.volumeProfile;
/// }
/// }
/// }
/// </code>
/// </example>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Volume", Order = 0)]
public class URPDefaultVolumeProfileSettings : IDefaultVolumeProfileSettings
{
#region Version
internal enum Version : int
{
Initial = 0,
}
[SerializeField][HideInInspector]
Version m_Version;
/// <summary>
/// Gets the current version of the volume profile settings.
/// </summary>
/// <remarks>
/// The version number tracks the changes made to the settings over time. It can be used to handle migration
/// of older settings in the future when updates are made to the system.
/// </remarks>
/// <example>
/// <code>
/// // Get the current version of the volume profile settings
/// int currentVersion = GraphicsSettings.GetRenderPipelineSettings&lt;URPDefaultVolumeProfileSettings&gt;().version;
/// </code>
/// </example>
public int version => (int)m_Version;
#endregion
[SerializeField]
VolumeProfile m_VolumeProfile;
/// <summary>
/// Gets or sets the default volume profile asset.
/// </summary>
/// <remarks>
/// This property allows you to configure the default volume profile used by the Volume Framework.
/// Setting this property will automatically update the volume profile used by the system.
/// </remarks>
/// <example>
/// <code>
/// // Set the default volume profile to a new profile
/// var urpDefaultVolumeProfileSettings = GraphicsSettings.GetRenderPipelineSettings&lt;URPDefaultVolumeProfileSettings&gt;();
/// urpDefaultVolumeProfileSettings.volumeProfile = newVolumeProfile;
/// </code>
/// </example>
public VolumeProfile volumeProfile
{
get => m_VolumeProfile;
set => this.SetValueAndNotify(ref m_VolumeProfile, value);
}
}
#if UNITY_EDITOR
//Overriding "Reset" in menu that is not called at URPDefaultVolumeProfileSettings creation such Reset()
struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu2<URPDefaultVolumeProfileSettings>
{
public void PopulateContextMenu(URPDefaultVolumeProfileSettings setting, SerializedProperty _, ref GenericMenu menu)
{
void Reset()
{
static VolumeProfile CopyVolumeProfileFromResourcesToAssets(VolumeProfile profileInResourcesFolder)
{
if (profileInResourcesFolder == null)
return null;
const string k_DefaultVolumeProfileName = "DefaultVolumeProfile";
const string k_DefaultVolumeProfilePath = "Assets/" + k_DefaultVolumeProfileName + ".asset";
var profile = AssetDatabase.LoadAssetAtPath<VolumeProfile>(k_DefaultVolumeProfilePath);
if (profile == null)
{
CoreUtils.EnsureFolderTreeInAssetFilePath(k_DefaultVolumeProfilePath);
AssetDatabase.CopyAsset(UnityEditor.AssetDatabase.GetAssetPath(profileInResourcesFolder), k_DefaultVolumeProfilePath);
profile = AssetDatabase.LoadAssetAtPath<VolumeProfile>(k_DefaultVolumeProfilePath);
}
else
{
profile.components.Clear();
foreach (var resourceComponent in profileInResourcesFolder.components)
{
var c = profile.Add(resourceComponent.GetType());
for (int i = 0; i < c.parameters.Count; i++)
{
c.parameters[i].SetValue(resourceComponent.parameters[i]);
}
}
}
return profile;
}
if (EditorGraphicsSettings.TryGetRenderPipelineSettingsForPipeline<UniversalRenderPipelineEditorAssets, UniversalRenderPipeline>(out var rpgs))
{
RenderPipelineGraphicsSettingsEditorUtility.Rebind(
new URPDefaultVolumeProfileSettings() { volumeProfile = CopyVolumeProfileFromResourcesToAssets(rpgs.defaultVolumeProfile) },
typeof(UniversalRenderPipeline)
);
}
}
menu.AddItem(new GUIContent("Reset"), false, Reset);
}
}
#endif
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3f36a6a4d730c3942afd169457cb4035
@@ -0,0 +1,54 @@
using System;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Rendering.Universal;
#endif
using UnityEngine.Rendering.Universal;
namespace UnityEngine.Rendering
{
/// <summary>
/// ReflectionProbe global settings class.
/// </summary>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Lighting", Order = 21)]
public class URPReflectionProbeSettings : IRenderPipelineGraphicsSettings
{
[SerializeField, HideInInspector] private int version = 1;
int IRenderPipelineGraphicsSettings.version => version;
bool IRenderPipelineGraphicsSettings.isAvailableInPlayerBuild => true;
[SerializeField, Tooltip("Use ReflectionProbe rotation. Enabling this will improve the appearance of reflections when the ReflectionProbe isn't axis aligned, but may worsen performance on lower end platforms.")]
private bool useReflectionProbeRotation = true;
/// <summary>
/// Whether to take ReflectionProbe rotation into account when rendering.
/// </summary>
public bool UseReflectionProbeRotation
{
get
{
#if UNITY_EDITOR
var mode = useReflectionProbeRotation ? SupportedRenderingFeatures.ReflectionProbeModes.Rotation : SupportedRenderingFeatures.ReflectionProbeModes.None;
if (mode != SupportedRenderingFeatures.active.reflectionProbeModes)
{
SupportedRenderingFeatures.active.reflectionProbeModes = mode;
}
#endif
return useReflectionProbeRotation;
}
#if UNITY_EDITOR
internal set
{
this.SetValueAndNotify(ref useReflectionProbeRotation, value, nameof(useReflectionProbeRotation));
if (QualitySettings.renderPipeline is UniversalRenderPipelineAsset urpAsset)
{
SupportedRenderingFeatures.active.reflectionProbeModes = value ? SupportedRenderingFeatures.ReflectionProbeModes.Rotation : SupportedRenderingFeatures.ReflectionProbeModes.None;
}
}
#endif
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 35922f772e2f746e0a76b49701b8c04a
@@ -0,0 +1,115 @@
using System;
using UnityEngine.Serialization;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A Graphics Settings container for settings related to shader stripping for <see cref="UniversalRenderPipeline"/>.
/// </summary>
/// <remarks>
/// To change those settings, go to Editor > Project Settings in the Graphics tab (URP).
/// Changing this through the API is only allowed in the Editor. In the Player, this raises an error.
///
/// This container is removed from all build Players.
/// </remarks>
/// <seealso cref="IRenderPipelineGraphicsSettings"/>
/// <example>
/// <para> Here is an example of how to determine if your project strips shader variants when building a Player with URP. </para>
/// <code>
/// using UnityEngine.Rendering;
/// using UnityEngine.Rendering.Universal;
///
/// public static class URPShaderStrippingHelper
/// {
/// public static bool enabled
/// {
/// get
/// {
/// var gs = GraphicsSettings.GetRenderPipelineSettings&lt;URPShaderStrippingSetting&gt;();
/// if (gs == null) //not in URP or in a Player
/// return false;
/// return gs.stripUnusedVariants;
/// }
/// }
/// }
/// </code>
/// </example>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Additional Shader Stripping Settings", Order = 40)]
[Categorization.ElementInfo(Order = 10)]
public class URPShaderStrippingSetting : IRenderPipelineGraphicsSettings
{
#region Version
internal enum Version : int
{
Initial = 0,
}
[SerializeField][HideInInspector]
private Version m_Version;
/// <summary>Indicates the current version of this settings container. Used exclusively for project upgrades.</summary>
public int version => (int)m_Version;
#endregion
#region SerializeFields
[SerializeField, FormerlySerializedAs("m_StripUnusedPostProcessingVariants")]
[Tooltip("Controls whether to automatically strip post processing shader variants and resources based on VolumeProfile components. Stripping is done based on VolumeProfiles in project, their usage in scenes is not considered.")]
bool m_StripUnusedPostProcessingVariantsAndResources = false;
[SerializeField]
[Tooltip("Controls whether to strip variants if the feature is disabled.")]
bool m_StripUnusedVariants = true;
[SerializeField]
[Tooltip("Controls whether Screen Coordinates Override shader variants are automatically stripped.")]
bool m_StripScreenCoordOverrideVariants = true;
[SerializeField]
[Tooltip("Controls whether unused 2D light shader variants are stripped based on scene analysis.")]
bool m_Strip2DUnusedVariants = false;
#endregion
#region Data Accessors
/// <summary>
/// Controls whether to automatically strip post processing shader variants and resources based on
/// <see cref="VolumeProfile"/> components. Stripping is done based on VolumeProfiles in project, their usage
/// in scenes is not considered.
/// </summary>
public bool stripUnusedPostProcessingVariants
{
get => m_StripUnusedPostProcessingVariantsAndResources;
set => this.SetValueAndNotify(ref m_StripUnusedPostProcessingVariantsAndResources, value);
}
/// <summary>
/// Controls whether to strip variants if the feature is disabled.
/// </summary>
public bool stripUnusedVariants
{
get => m_StripUnusedVariants;
set => this.SetValueAndNotify(ref m_StripUnusedVariants, value);
}
/// <summary>
/// Controls whether Screen Coordinates Override shader variants are automatically stripped.
/// </summary>
public bool stripScreenCoordOverrideVariants
{
get => m_StripScreenCoordOverrideVariants;
set => this.SetValueAndNotify(ref m_StripScreenCoordOverrideVariants, value);
}
/// <summary>
/// Controls whether unused 2D light shader variants are stripped based on scene analysis.
/// </summary>
public bool strip2DUnusedVariants
{
get => m_Strip2DUnusedVariants;
set => this.SetValueAndNotify(ref m_Strip2DUnusedVariants, value);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2b7f0db433bbf340871ffeb0134a898
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,70 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A Graphics Settings container for settings related to terrain shaders in <see cref="UniversalRenderPipeline"/>.
/// </summary>
/// <remarks>
/// To change those settings, go to Editor > Project Settings in the Graphics tab (URP).
/// Changing those settings through the API is only allowed in the Editor. In the Player, this raises an error.
///
/// Unity removes this container from Players at build time.
/// </remarks>
/// <seealso cref="IRenderPipelineGraphicsSettings"/>
/// <example>
/// <para> Here is an example of how to determine if your project has included terrain shaders when building a Player with URP. </para>
/// <code>
/// using UnityEngine.Rendering;
/// using UnityEngine.Rendering.Universal;
///
/// public static class URPTerrainShaderHelper
/// {
/// public static bool enabled
/// {
/// get
/// {
/// var gs = GraphicsSettings.GetRenderPipelineSettings&lt;URPTerrainShaderSetting&gt;();
/// if (gs == null) //not in URP or in a Player
/// return false;
/// return gs.includeTerrainShaders;
/// }
/// }
/// }
/// </code>
/// </example>
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Terrain Shader Inclusion Settings", Order = 50)]
[Categorization.ElementInfo(Order = 10)]
public class URPTerrainShaderSetting : IRenderPipelineGraphicsSettings
{
#region Version
internal enum Version : int
{
Initial = 0,
}
[SerializeField][HideInInspector]
private Version m_Version;
/// <summary>Indicates the current version of this settings container. Used exclusively for project upgrades.</summary>
public int version => (int)m_Version;
#endregion
#region Settings
[SerializeField]
[Tooltip("Include terrain shaders in build even if not referenced.")]
bool m_IncludeTerrainShaders = true;
/// <summary>
/// Controls whether terrain shaders are included in the build.
/// </summary>
public bool includeTerrainShaders
{
get => m_IncludeTerrainShaders;
set => this.SetValueAndNotify(ref m_IncludeTerrainShaders, value);
}
#endregion
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2f5d344954b35bc4faad3771ebd6ccd8