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

73 行
3.2 KiB

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEditor.Rendering.Universal
{
[CustomEditor(typeof(ForwardRendererData), true)]
[MovedFrom("UnityEditor.Rendering.LWRP")] public class ForwardRendererDataEditor : ScriptableRendererDataEditor
{
private static class Styles
{
public static readonly GUIContent RendererTitle = new GUIContent("Forward Renderer", "Custom Forward Renderer for LWRP.");
public static readonly GUIContent OpaqueMask = new GUIContent("Default Layer Mask", "Controls which layers to globally include in the Custom Forward Renderer.");
public static readonly GUIContent defaultStencilStateLabel = EditorGUIUtility.TrTextContent("Default Stencil State", "Configure stencil state for the opaque and transparent render passes.");
}
SerializedProperty m_OpaqueLayerMask;
SerializedProperty m_TransparentLayerMask;
SerializedProperty m_DefaultStencilState;
SerializedProperty m_PostProcessData;
SerializedProperty m_Shaders;
private void OnEnable()
{
m_OpaqueLayerMask = serializedObject.FindProperty("m_OpaqueLayerMask");
m_TransparentLayerMask = serializedObject.FindProperty("m_TransparentLayerMask");
m_DefaultStencilState = serializedObject.FindProperty("m_DefaultStencilState");
m_PostProcessData = serializedObject.FindProperty("postProcessData");
m_Shaders = serializedObject.FindProperty("shaders");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.Space();
EditorGUILayout.LabelField(Styles.RendererTitle, EditorStyles.boldLabel); // Title
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_OpaqueLayerMask, Styles.OpaqueMask);
if (EditorGUI.EndChangeCheck()) // We copy the opaque mask to the transparent mask, later we might expose both
m_TransparentLayerMask.intValue = m_OpaqueLayerMask.intValue;
EditorGUILayout.PropertyField(m_PostProcessData);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Overrides", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_DefaultStencilState, Styles.defaultStencilStateLabel, true);
EditorGUILayout.Space();
serializedObject.ApplyModifiedProperties();
base.OnInspectorGUI(); // Draw the base UI, contains ScriptableRenderFeatures list
// Add a "Reload All" button in inspector when we are in developer's mode
if (EditorPrefs.GetBool("DeveloperMode"))
{
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_Shaders, true);
if (GUILayout.Button("Reload All"))
{
var resources = target as ForwardRendererData;
resources.shaders = null;
ResourceReloader.ReloadAllNullIn(target, UniversalRenderPipelineAsset.packagePath);
}
}
}
}
}