浏览代码

Updates to the LW Asset Inspector

/main
Martin Thorzen 7 年前
当前提交
a89bfc3d
共有 2 个文件被更改,包括 72 次插入93 次删除
  1. 4
      com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs
  2. 161
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightPipelineAssetEditor.cs

4
com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs


[SerializeField] bool m_LocalShadowsSupported = true;
[SerializeField] ShadowResolution m_LocalShadowsAtlasResolution = ShadowResolution._512;
[SerializeField] bool m_SoftShadowsSupported = false;
[SerializeField] bool m_CustomShaderVariantStrippingSettings = false;
//[SerializeField] bool m_CustomShaderVariantStrippingSettings = false;
[SerializeField] bool m_KeepAdditionalLightVariants = true;
[SerializeField] bool m_KeepVertexLightVariants = true;
[SerializeField] bool m_KeepDirectionalShadowVariants = true;

public bool customShaderVariantStripping
{
get { return m_CustomShaderVariantStrippingSettings; }
get { return false; }
}
public bool keepAdditionalLightVariants

161
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightPipelineAssetEditor.cs


{
internal class Styles
{
public static GUIContent generalSettingsLabel = new GUIContent("General");
public static GUIContent directionalShadowLabel = new GUIContent("Directional Shadows");
public static GUIContent localShadowLabel = new GUIContent("Local Shadows");
public static GUIContent capabilitiesLabel = new GUIContent("Capabilities");
public static GUIContent renderScaleLabel = new GUIContent("Render Scale", "Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution. When in VR mode, VR scaling configuration is used instead.");

public static GUIContent msaaContent = new GUIContent("Anti Aliasing (MSAA)", "Controls the global anti aliasing settings.");
public static GUIContent dynamicBatching = new GUIContent("Dynamic Batching", "If enabled the pipeline will batch drawcalls with few triangles together by copying their vertex buffers into a shared buffer on a per-frame basis.");
public static GUIContent supportsSoftShadows = new GUIContent("Soft Shadows", "If enabled pipeline will perform shadow filtering. Otherwise all lights that cast shadows will fallback to perform a single shadow sample.");
public static GUIContent supportsDirectionalShadows = new GUIContent("Directional Shadows", "If enabled shadows will be supported for directional lights.");
public static GUIContent supportsSoftShadows = new GUIContent("Soft Shadows", "If enabled pipeline will perform shadow filtering. Otherwise all lights that cast shadows will fallback to perform a single shadow sample.\nNeeds either Directional or Local Shadows to be enabled in the Capabilities section.");
public static GUIContent supportsDirectionalShadows = new GUIContent("Directional Shadows", "If enabled shadows will be supported for directional lights.\nNeeds Directional Shadows to be enabled in the Capabilities section.");
public static GUIContent shadowDistance = new GUIContent("Distance", "Max shadow rendering distance.");

public static GUIContent shadowCascadeSplit = new GUIContent("Cascades Split",
"Percentages to split shadow volume");
public static GUIContent supportsLocalShadows = new GUIContent("Local Shadows", "If enabled shadows will be supported for spot lights.");
public static GUIContent supportsLocalShadows = new GUIContent("Local Shadows", "If enabled shadows will be supported for spot lights.\nNeeds Local Shadows to be enabled in the Capabilities section.");
public static GUIContent localShadowsAtlasResolution = new GUIContent("Atlas Resolution",
"All local lights are packed into a single atlas. This setting controls the atlas size.");

SerializedProperty m_LocalShadowsAtlasResolutionProp;
SerializedProperty m_CustomShaderVariantStripSettingsProp;
SerializedProperty m_KeepAdditionalLightsProp;
SerializedProperty m_KeepVertexLightsProp;
SerializedProperty m_KeepDirectionalShadowsProp;
SerializedProperty m_KeepLocalShadowsProp;
SerializedProperty m_KeepSoftShadowsProp;
// SerializedProperty m_KeepAdditionalLightsProp;
// SerializedProperty m_KeepVertexLightsProp;
// SerializedProperty m_KeepDirectionalShadowsProp;
// SerializedProperty m_KeepLocalShadowsProp;
// SerializedProperty m_KeepSoftShadowsProp;
public override void OnInspectorGUI()
{

DrawRenderingSettings();
DrawStrippingSettings();
DrawGeneralSettings();
//DrawStrippingSettings();
serializedObject.ApplyModifiedProperties();
}

m_LocalShadowsAtlasResolutionProp = serializedObject.FindProperty("m_LocalShadowsAtlasResolution");
m_SoftShadowsSupportedProp = serializedObject.FindProperty("m_SoftShadowsSupported");
m_CustomShaderVariantStripSettingsProp = serializedObject.FindProperty("m_CustomShaderVariantStrippingSettings");
m_KeepAdditionalLightsProp = serializedObject.FindProperty("m_KeepAdditionalLightVariants");
m_KeepVertexLightsProp = serializedObject.FindProperty("m_KeepVertexLightVariants");
m_KeepDirectionalShadowsProp = serializedObject.FindProperty("m_KeepDirectionalShadowVariants");
m_KeepLocalShadowsProp = serializedObject.FindProperty("m_KeepLocalShadowVariants");
m_KeepSoftShadowsProp = serializedObject.FindProperty("m_KeepSoftShadowVariants");
//m_CustomShaderVariantStripSettingsProp = serializedObject.FindProperty("m_CustomShaderVariantStrippingSettings");
// m_KeepAdditionalLightsProp = serializedObject.FindProperty("m_KeepAdditionalLightVariants");
// m_KeepVertexLightsProp = serializedObject.FindProperty("m_KeepVertexLightVariants");
// m_KeepDirectionalShadowsProp = serializedObject.FindProperty("m_KeepDirectionalShadowVariants");
// m_KeepLocalShadowsProp = serializedObject.FindProperty("m_KeepLocalShadowVariants");
// m_KeepSoftShadowsProp = serializedObject.FindProperty("m_KeepSoftShadowVariants");
m_ShowSoftParticles.valueChanged.AddListener(Repaint);
m_ShowSoftParticles.value = m_RequireSoftParticlesProp.boolValue;

m_ShowOpaqueTextureScale.target = m_RequireOpaqueTextureProp.boolValue;
}
void DrawAnimatedProperty(SerializedProperty prop, GUIContent content, AnimBool animation)
void DrawGeneralSettings()
using (var group = new EditorGUILayout.FadeGroupScope(animation.faded))
if (group.visible)
EditorGUILayout.PropertyField(prop, content);
}
void DrawAnimatedPopup(SerializedProperty prop, GUIContent content, string[] options, AnimBool animation)
{
using (var group = new EditorGUILayout.FadeGroupScope(animation.faded))
if (group.visible)
CoreEditorUtils.DrawPopup(content, prop, options);
}
void DrawRenderingSettings()
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(Styles.renderingLabel, EditorStyles.boldLabel);
EditorGUILayout.LabelField(Styles.generalSettingsLabel, EditorStyles.boldLabel);
//EditorGUILayout.BeginHorizontal();
//EditorGUILayout.LabelField(Styles.renderScaleLabel);
//EditorGUILayout.EndHorizontal();
//EditorGUILayout.BeginHorizontal();
//EditorGUILayout.LabelField(Styles.maxPixelLightsLabel);
//EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(m_SupportsVertexLightProp, Styles.enableVertexLightLabel);
EditorGUILayout.PropertyField(m_RequireDepthTextureProp, Styles.requireDepthTexture);
//EditorGUI.indentLevel++;
//if(m_RequireDepthTextureProp.boolValue)
EditorGUI.BeginDisabledGroup(!m_RequireDepthTextureProp.boolValue);
EditorGUILayout.PropertyField(m_RequireSoftParticlesProp, Styles.requireSoftParticles);
EditorGUI.EndDisabledGroup();
//EditorGUI.indentLevel--;
//DrawAnimatedProperty(m_RequireSoftParticlesProp, Styles.requireSoftParticles, m_ShowSoftParticles);
EditorGUILayout.PropertyField(m_RequireOpaqueTextureProp, Styles.requireOpaqueTexture);
EditorGUI.indentLevel++;
EditorGUI.BeginDisabledGroup(!m_RequireOpaqueTextureProp.boolValue);
EditorGUILayout.PropertyField(m_OpaqueDownsamplingProp, Styles.opaqueDownsampling);
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel--;
//DrawAnimatedPopup(m_OpaqueDownsamplingProp, Styles.opaqueDownsampling, Styles.opaqueDownsamplingOptions, m_ShowOpaqueTextureScale);
EditorGUILayout.PropertyField(m_HDR, Styles.hdrContent);
EditorGUILayout.PropertyField(m_MSAA, Styles.msaaContent);
EditorGUILayout.PropertyField(m_SupportsDynamicBatching, Styles.dynamicBatching);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
void DrawCapabilitiesSettings()
{
EditorGUILayout.LabelField(Styles.capabilitiesLabel, EditorStyles.boldLabel);
DrawShadowSettings();
}
void DrawShadowSettings()
{
//EditorGUILayout.LabelField(Styles.shadowLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_DirectionalShadowsSupportedProp, Styles.supportsDirectionalShadows);
EditorGUILayout.LabelField(Styles.directionalShadowLabel);
EditorGUILayout.FloatField(Styles.shadowDistance, m_ShadowDistanceProp.floatValue));
EditorGUILayout.FloatField(Styles.shadowDistance, m_ShadowDistanceProp.floatValue));
CoreEditorUtils.DrawPopup(Styles.shadowCascades, m_ShadowCascadesProp, Styles.shadowCascadeOptions);
ShadowCascades cascades = (ShadowCascades)m_ShadowCascadesProp.intValue;

EditorGUILayout.Space();
}
EditorGUILayout.PropertyField(m_LocalShadowSupportedProp, Styles.supportsLocalShadows);
EditorGUILayout.LabelField(Styles.localShadowLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_LocalShadowsAtlasResolutionProp, Styles.localShadowsAtlasResolution);
EditorGUI.indentLevel--;

if (directionalShadows || localShadows)
EditorGUILayout.PropertyField(m_SoftShadowsSupportedProp, Styles.supportsSoftShadows);
EditorGUI.indentLevel--;
EditorGUILayout.Space();

void DrawStrippingSettings()
void DrawCapabilitiesSettings()
EditorGUILayout.LabelField(StrippingStyles.strippingLabel, EditorStyles.boldLabel);
EditorGUILayout.LabelField(Styles.capabilitiesLabel, EditorStyles.boldLabel);
CoreEditorUtils.DrawPopup(StrippingStyles.pipelineCapabilitiesLabel, m_CustomShaderVariantStripSettingsProp, StrippingStyles.strippingOptions);
if (m_CustomShaderVariantStripSettingsProp.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_KeepAdditionalLightsProp, StrippingStyles.localLightsLabel);
EditorGUILayout.PropertyField(m_KeepVertexLightsProp, StrippingStyles.vertexLightsLabel);
EditorGUILayout.PropertyField(m_KeepDirectionalShadowsProp, StrippingStyles.directionalShadowsLabel);
EditorGUILayout.PropertyField(m_KeepLocalShadowsProp, StrippingStyles.localShadowsLabel);
EditorGUILayout.PropertyField(m_KeepSoftShadowsProp, StrippingStyles.softShadowsLabel);
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(m_SupportsVertexLightProp, Styles.enableVertexLightLabel);
EditorGUILayout.PropertyField(m_RequireDepthTextureProp, Styles.requireDepthTexture);
EditorGUI.BeginDisabledGroup(!m_RequireDepthTextureProp.boolValue);
EditorGUILayout.PropertyField(m_RequireSoftParticlesProp, Styles.requireSoftParticles);
EditorGUI.EndDisabledGroup();
EditorGUILayout.PropertyField(m_RequireOpaqueTextureProp, Styles.requireOpaqueTexture);
EditorGUI.indentLevel++;
EditorGUI.BeginDisabledGroup(!m_RequireOpaqueTextureProp.boolValue);
EditorGUILayout.PropertyField(m_OpaqueDownsamplingProp, Styles.opaqueDownsampling);
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel--;
EditorGUILayout.PropertyField(m_HDR, Styles.hdrContent);
EditorGUILayout.PropertyField(m_MSAA, Styles.msaaContent);
EditorGUILayout.PropertyField(m_SupportsDynamicBatching, Styles.dynamicBatching);
EditorGUILayout.PropertyField(m_DirectionalShadowsSupportedProp, Styles.supportsDirectionalShadows);
EditorGUILayout.PropertyField(m_LocalShadowSupportedProp, Styles.supportsLocalShadows);
// void DrawStrippingSettings()
// {
// EditorGUILayout.LabelField(StrippingStyles.strippingLabel, EditorStyles.boldLabel);
// EditorGUI.indentLevel++;
// CoreEditorUtils.DrawPopup(StrippingStyles.pipelineCapabilitiesLabel, m_CustomShaderVariantStripSettingsProp, StrippingStyles.strippingOptions);
// if (m_CustomShaderVariantStripSettingsProp.boolValue)
// {
// EditorGUI.indentLevel++;
// EditorGUILayout.PropertyField(m_KeepAdditionalLightsProp, StrippingStyles.localLightsLabel);
// EditorGUILayout.PropertyField(m_KeepVertexLightsProp, StrippingStyles.vertexLightsLabel);
// EditorGUILayout.PropertyField(m_KeepDirectionalShadowsProp, StrippingStyles.directionalShadowsLabel);
// EditorGUILayout.PropertyField(m_KeepLocalShadowsProp, StrippingStyles.localShadowsLabel);
// EditorGUILayout.PropertyField(m_KeepSoftShadowsProp, StrippingStyles.softShadowsLabel);
// EditorGUI.indentLevel--;
// }
// EditorGUI.indentLevel--;
// EditorGUILayout.Space();
// EditorGUILayout.Space();
// }
}
}
正在加载...
取消
保存