Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

101 行
3.7 KiB

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
#endif
using System;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.Rendering.Universal
{
[Serializable, ReloadGroup]
[MovedFrom("UnityEngine.Rendering.LWRP")]
public class ForwardRendererData : ScriptableRendererData
{
#if UNITY_EDITOR
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1812")]
internal class CreateForwardRendererAsset : EndNameEditAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
{
var instance = CreateInstance<ForwardRendererData>();
AssetDatabase.CreateAsset(instance, pathName);
ResourceReloader.ReloadAllNullIn(instance, UniversalRenderPipelineAsset.packagePath);
Selection.activeObject = instance;
}
}
[MenuItem("Assets/Create/Rendering/Universal Render Pipeline/Forward Renderer", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateForwardRendererData()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateForwardRendererAsset>(), "CustomForwardRendererData.asset", null, null);
}
#endif
[Serializable, ReloadGroup]
public sealed class ShaderResources
{
[Reload("Shaders/Utils/Blit.shader")]
public Shader blitPS;
[Reload("Shaders/Utils/CopyDepth.shader")]
public Shader copyDepthPS;
[Reload("Shaders/Utils/ScreenSpaceShadows.shader")]
public Shader screenSpaceShadowPS;
[Reload("Shaders/Utils/Sampling.shader")]
public Shader samplingPS;
}
[Reload("Runtime/Data/PostProcessData.asset")]
public PostProcessData postProcessData = null;
public ShaderResources shaders = null;
[SerializeField] LayerMask m_OpaqueLayerMask = -1;
[SerializeField] LayerMask m_TransparentLayerMask = -1;
[SerializeField] StencilStateData m_DefaultStencilState = null;
protected override ScriptableRenderer Create()
{
m_DefaultStencilState = new StencilStateData();
#if UNITY_EDITOR
if (!Application.isPlaying)
{
ResourceReloader.ReloadAllNullIn(this, UniversalRenderPipelineAsset.packagePath);
ResourceReloader.ReloadAllNullIn(postProcessData, UniversalRenderPipelineAsset.packagePath);
}
#endif
return new ForwardRenderer(this);
}
internal LayerMask opaqueLayerMask => m_OpaqueLayerMask;
public LayerMask transparentLayerMask => m_TransparentLayerMask;
public StencilStateData defaultStencilState => m_DefaultStencilState;
protected override void OnEnable()
{
base.OnEnable();
// Upon asset creation, OnEnable is called and `shaders` reference is not yet initialized
// We need to call the OnEnable for data migration when updating from old versions of LWRP that
// serialized resources in a different format. Early returning here when OnEnable is called
// upon asset creation is fine because we guarantee new assets get created with all resources initialized.
if (shaders == null)
return;
#if UNITY_EDITOR
try
{
ResourceReloader.ReloadAllNullIn(this, UniversalRenderPipelineAsset.packagePath);
ResourceReloader.ReloadAllNullIn(postProcessData, UniversalRenderPipelineAsset.packagePath);
}
catch {}
#endif
}
}
}