public static void DrawOutputLayerProperties(Rect rect, SerializedCompositionLayer serializedProperties, System.Action resetRenderTargetCallback) { rect.y += CompositorStyle.k_ListItemPading; rect.height = CompositorStyle.k_SingleLineHeight; EditorGUI.PropertyField(rect, serializedProperties.colorFormat, Styles.k_BufferFormat); rect.y += CompositorStyle.k_Spacing; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(rect, serializedProperties.resolutionScale, Styles.k_Resolution); if (EditorGUI.EndChangeCheck()) { // if the resolution changes, reset the RTs resetRenderTargetCallback(); } rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.outputRenderer, Styles.k_OutputRenderer); rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.aovBitmask, Styles.k_AOVs); rect.y += CompositorStyle.k_Spacing; HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; if (serializedProperties.aovBitmask.intValue != 0 && hdrp && !hdrp.currentPlatformRenderPipelineSettings.supportRuntimeAOVAPI) { Rect infoRect = rect; infoRect.height = Styles.infoBoxHeight; EditorGUI.HelpBox(infoRect, Styles.k_AlphaInfoPost, MessageType.Info); rect.y += Styles.infoBoxHeight; } }
public static void DrawOutputLayerProperties(Rect rect, SerializedCompositionLayer serializedProperties, System.Action resetRenderTargetCallback) { rect.y += CompositorStyle.k_ListItemPading; rect.height = CompositorStyle.k_SingleLineHeight; EditorGUI.PropertyField(rect, serializedProperties.colorFormat, Styles.k_BufferFormat); rect.y += CompositorStyle.k_Spacing; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(rect, serializedProperties.resolutionScale, Styles.k_Resolution); if (EditorGUI.EndChangeCheck()) { // if the resolution changes, reset the RTs resetRenderTargetCallback(); } rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.outputRenderer, Styles.k_OutputRenderer); rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.aovBitmask, Styles.k_AOVs); rect.y += CompositorStyle.k_Spacing; }
public static void DrawStackedLayerProperties(Rect rect, SerializedCompositionLayer serializedProperties, ReorderableList filterList) { rect.y += CompositorStyle.k_ListItemPading; rect.height = CompositorStyle.k_SingleLineHeight; EditorGUI.PropertyField(rect, serializedProperties.layerName, Styles.k_NameContent); rect.y += CompositorStyle.k_Spacing; switch (serializedProperties.inputLayerType.enumValueIndex) { case (int)CompositorLayer.LayerType.Camera: EditorGUI.PropertyField(rect, serializedProperties.inputCamera, Styles.k_Camera); break; case (int)CompositorLayer.LayerType.Video: EditorGUI.PropertyField(rect, serializedProperties.inputVideo, Styles.k_Video); break; case (int)CompositorLayer.LayerType.Image: EditorGUI.PropertyField(rect, serializedProperties.inputTexture, Styles.k_Image); rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.fitType); break; default: // This will happen if someone adds a new layer type and does not update this switch statement Debug.Log("Unknown layer type: Please add code here to handle this type of layer."); break; } rect.y += 1.5f * CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.clearDepth, Styles.k_ClearDepth); rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.clearAlpha, Styles.k_ClearAlpha); rect.y += 1.5f * CompositorStyle.k_Spacing; // The clear mode should be visible / configurable only for the first layer in the stack. For the other layers we set a camera-stacking specific clear-mode . if (serializedProperties.positionInStack.intValue == 0) { DrawPropertyHelper(rect, Styles.k_ClearMode, serializedProperties.overrideClearMode, serializedProperties.clearMode); rect.y += CompositorStyle.k_Spacing; } DrawPropertyHelper(rect, Styles.k_AAMode, serializedProperties.overrideAA, serializedProperties.aaMode); rect.y += CompositorStyle.k_Spacing; DrawPropertyHelper(rect, Styles.k_CullingMask, serializedProperties.overrideCulling, serializedProperties.cullingMaskProperty); rect.y += CompositorStyle.k_Spacing; DrawPropertyHelper(rect, Styles.k_VolumeMask, serializedProperties.overrideVolume, serializedProperties.volumeMask); rect.y += CompositorStyle.k_Spacing; Rect filterRect = rect; filterRect.y += 0.5f * CompositorStyle.k_Spacing; filterList.DoList(filterRect); }
public static void DrawItemInList(Rect rect, SerializedCompositionLayer serialized, RenderTexture thumbnail, float aspectRatio, bool isAlphaEnbaled) { bool isCameraStack = serialized.outTarget.intValue == (int)CompositorLayer.OutputTarget.CameraStack; // Compute the desired indentation { const float listBorder = 2.0f; rect.x = isCameraStack ? rect.x + CompositorStyle.k_ListItemStackPading + listBorder : rect.x + listBorder; rect.width = isCameraStack ? rect.width - CompositorStyle.k_ListItemStackPading - listBorder : rect.width - listBorder; rect.y += CompositorStyle.k_ListItemPading; rect.height = EditorGUIUtility.singleLineHeight; } if (thumbnail) { Rect newRect = rect; newRect.width = EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(newRect, serialized.show, GUIContent.none); rect.x += CompositorStyle.k_CheckboxSpacing; Rect previewRect = rect; previewRect.width = CompositorStyle.k_ThumbnailSize * aspectRatio; previewRect.height = CompositorStyle.k_ThumbnailSize; EditorGUI.DrawPreviewTexture(previewRect, thumbnail); previewRect.x += previewRect.width + CompositorStyle.k_ThumbnailDivider; rect.x += previewRect.width + CompositorStyle.k_ThumbnailSpacing; rect.width -= previewRect.width + CompositorStyle.k_ThumbnailSpacing; if (isAlphaEnbaled && (thumbnail.format == RenderTextureFormat.ARGBHalf || thumbnail.format == RenderTextureFormat.ARGBFloat || thumbnail.format == RenderTextureFormat.ARGB64)) { EditorGUI.DrawTextureAlpha(previewRect, thumbnail); rect.x += previewRect.width + CompositorStyle.k_ThumbnailSpacing; rect.width -= previewRect.width + CompositorStyle.k_ThumbnailSpacing; } rect.y += CompositorStyle.k_LabelVerticalOffset; EditorGUI.LabelField(rect, serialized.layerName.stringValue); } else { Rect newRect = rect; newRect.width = EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(newRect, serialized.show, GUIContent.none); newRect.x += CompositorStyle.k_CheckboxSpacing; if (isCameraStack) { Rect iconRect = newRect; iconRect.width = CompositorStyle.k_IconSize; iconRect.height = CompositorStyle.k_IconSize; iconRect.y -= CompositorStyle.k_IconVerticalOffset; switch (serialized.inputLayerType.enumValueIndex) { case (int)CompositorLayer.LayerType.Camera: GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(Camera)).image); break; case (int)CompositorLayer.LayerType.Video: GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(UnityEngine.Video.VideoClip)).image); break; case (int)CompositorLayer.LayerType.Image: GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(Texture)).image); break; default: // This will happen if someone adds a new layer type and does not update this switch statement Debug.Log("Unknown layer type: Please add code here to draw this type of layer."); break; } newRect.x += CompositorStyle.k_IconSize + CompositorStyle.k_IconSpacing; } newRect.width = rect.width - newRect.x; EditorGUI.LabelField(newRect, serialized.layerName.stringValue); } }
void DrawLayerProperties(Rect rect, SerializedCompositionLayer serializedProperties, int layerIndex, RenderTexture preview = null) { if (serializedProperties == null) { return; } if (serializedProperties.outTarget.intValue != (int)CompositorLayer.OutputTarget.CameraStack) { CompositionLayerUI.DrawOutputLayerProperties(rect, serializedProperties, m_compositionManager.DeleteLayerRTs); } else { if (m_filterList == null) { m_filterList = new ReorderableList(serializedProperties.inputFilters.serializedObject, serializedProperties.inputFilters, true, true, true, true); m_filterList.onAddCallback = (list) => { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Chroma Keying"), false, AddFilterOfTypeCallback, 0); menu.AddItem(new GUIContent("Alpha Mask"), false, AddFilterOfTypeCallback, 1); menu.ShowAsContext(); EditorUtility.SetDirty(m_compositionManager.profile); EditorUtility.SetDirty(m_compositionManager); }; m_filterList.drawElementCallback = (Rect r, int index, bool isActive, bool isFocused) => { if (index < m_SerializedLayerProperties[m_layerList.index].filterList.Count) { var serializedFilter = m_SerializedLayerProperties[m_layerList.index].filterList[index]; CompositionFilterUI.Draw(r, serializedFilter); } }; m_filterList.drawNoneElementCallback = (Rect r) => { using (new EditorGUI.DisabledScope(true)) { EditorGUI.LabelField(r, "List Is Empty", EditorStyles.label); } }; m_filterList.drawHeaderCallback = (Rect r) => { EditorGUI.LabelField(r, Styles.k_InputFilters, EditorStyles.largeLabel); }; m_filterList.elementHeightCallback = (index) => { if (index < m_SerializedLayerProperties[m_layerList.index].filterList.Count) { var filter = m_SerializedLayerProperties[m_layerList.index].filterList[index]; return(filter.GetHeight()); } return(0); }; } CompositionLayerUI.DrawStackedLayerProperties(rect, serializedProperties, m_filterList); } }
public static void DrawStackedLayerProperties(Rect rect, SerializedCompositionLayer serializedProperties, ReorderableList filterList) { rect.y += CompositorStyle.k_ListItemPading; rect.height = CompositorStyle.k_SingleLineHeight; EditorGUI.PropertyField(rect, serializedProperties.layerName, Styles.k_NameContent); rect.y += CompositorStyle.k_Spacing; switch (serializedProperties.inputLayerType.enumValueIndex) { case (int)CompositorLayer.LayerType.Camera: EditorGUI.PropertyField(rect, serializedProperties.inputCamera, Styles.k_Camera); break; case (int)CompositorLayer.LayerType.Video: EditorGUI.PropertyField(rect, serializedProperties.inputVideo, Styles.k_Video); break; case (int)CompositorLayer.LayerType.Image: EditorGUI.PropertyField(rect, serializedProperties.inputTexture, Styles.k_Image); rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.fitType); break; default: // This will happen if someone adds a new layer type and does not update this switch statement Debug.Log("Unknown layer type: Please add code here to handle this type of layer."); break; } rect.y += 1.5f * CompositorStyle.k_Spacing; using (new EditorGUI.DisabledScope(serializedProperties.positionInStack.intValue == 0)) { EditorGUI.PropertyField(rect, serializedProperties.clearDepth, Styles.k_ClearDepth); rect.y += CompositorStyle.k_Spacing; } EditorGUI.PropertyField(rect, serializedProperties.clearAlpha, Styles.k_ClearAlpha); rect.y += 1.0f * CompositorStyle.k_Spacing; // Draw a min/max slider for tha alpha range { const float spacing = 5; var labelRect = new Rect(rect.x, rect.y, EditorGUIUtility.labelWidth, rect.height); EditorGUI.PrefixLabel(labelRect, Styles.k_AlphaRange); var minLabelRect = rect; minLabelRect.x += EditorGUIUtility.labelWidth; minLabelRect.width = EditorGUIUtility.fieldWidth / 2; serializedProperties.alphaMin.floatValue = EditorGUI.FloatField(minLabelRect, serializedProperties.alphaMin.floatValue); GUI.SetNextControlName("AlphaMinMaxSlider"); var sliderRect = rect; sliderRect.x += EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth / 2 + spacing; sliderRect.width -= (EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth + 2 * spacing); float minVal = serializedProperties.alphaMin.floatValue; float maxVal = serializedProperties.alphaMax.floatValue; EditorGUI.MinMaxSlider(sliderRect, ref minVal, ref maxVal, 0, 1); if (serializedProperties.alphaMin.floatValue != minVal || serializedProperties.alphaMax.floatValue != maxVal) { // Note: We need to move the focus when the slider changes, otherwise the textField will not update GUI.FocusControl("AlphaMinMaxSlider"); serializedProperties.alphaMin.floatValue = minVal; serializedProperties.alphaMax.floatValue = maxVal; } var maxLabelRect = rect; maxLabelRect.x = sliderRect.x + sliderRect.width + spacing; maxLabelRect.width = EditorGUIUtility.fieldWidth / 2; serializedProperties.alphaMax.floatValue = EditorGUI.FloatField(maxLabelRect, serializedProperties.alphaMax.floatValue); // sanity checks if (serializedProperties.alphaMax.floatValue < serializedProperties.alphaMin.floatValue) { serializedProperties.alphaMax.floatValue = serializedProperties.alphaMin.floatValue; } if (serializedProperties.alphaMax.floatValue > 1) { serializedProperties.alphaMax.floatValue = 1; } if (serializedProperties.alphaMin.floatValue > serializedProperties.alphaMax.floatValue) { serializedProperties.alphaMin.floatValue = serializedProperties.alphaMax.floatValue; } if (serializedProperties.alphaMin.floatValue < 0) { serializedProperties.alphaMin.floatValue = 0; } } rect.y += 1.5f * CompositorStyle.k_Spacing; // The clear mode should be visible / configurable only for the first layer in the stack. For the other layers we set a camera-stacking specific clear-mode . using (new EditorGUI.DisabledScope(serializedProperties.positionInStack.intValue != 0)) { DrawPropertyHelper(rect, Styles.k_ClearMode, serializedProperties.overrideClearMode, serializedProperties.clearMode); rect.y += CompositorStyle.k_Spacing; } DrawPropertyHelper(rect, Styles.k_AAMode, serializedProperties.overrideAA, serializedProperties.aaMode); rect.y += CompositorStyle.k_Spacing; DrawPropertyHelper(rect, Styles.k_CullingMask, serializedProperties.overrideCulling, serializedProperties.cullingMaskProperty); rect.y += CompositorStyle.k_Spacing; DrawPropertyHelper(rect, Styles.k_VolumeMask, serializedProperties.overrideVolume, serializedProperties.volumeMask); rect.y += CompositorStyle.k_Spacing; Rect filterRect = rect; filterRect.y += 0.5f * CompositorStyle.k_Spacing; filterList.DoList(filterRect); }
public static void DrawOutputLayerProperties(Rect rect, SerializedCompositionLayer serializedProperties, System.Action resetRenderTargetCallback) { rect.y += CompositorStyle.k_ListItemPading; rect.height = CompositorStyle.k_SingleLineHeight; EditorGUI.PropertyField(rect, serializedProperties.colorFormat, Styles.k_BufferFormat); rect.y += CompositorStyle.k_Spacing; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(rect, serializedProperties.resolutionScale, Styles.k_Resolution); if (EditorGUI.EndChangeCheck()) { // if the resolution changes, reset the RTs resetRenderTargetCallback(); } rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.outputRenderer, Styles.k_OutputRenderer); rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.aovBitmask, Styles.k_AOVs); rect.y += CompositorStyle.k_Spacing; if (serializedProperties.aovBitmask.intValue != 0) { // [case 1288744] Enable async compile for the debug shaders to avoid editor freeze when the user selects AOVs s_AsyncCompileState = ShaderUtil.allowAsyncCompilation; ShaderUtil.allowAsyncCompilation = true; // Note: We cannot check immediately if "anythingCompiling", this has to be delayed for the next frame if (s_HasStartedCompiling && ShaderUtil.anythingCompiling) { // Display a message while we are compiling the shaders Rect infoRect = rect; // Compute the height of the infobox based on the width of the window and the amount of text GUIStyle.none.CalcMinMaxWidth(new GUIContent(Styles.k_ShaderCompilationWarning), out float minWidth, out float maxWidth); float lines = Mathf.Max(2, Mathf.CeilToInt(maxWidth / (rect.width - Styles.infoBoxIconWidth))); infoRect.height = lines * CompositorStyle.k_Spacing; EditorGUI.HelpBox(infoRect, Styles.k_ShaderCompilationWarning, MessageType.Warning); rect.y += infoRect.height + EditorGUIUtility.standardVerticalSpacing; } else { // If the shaders have finished compiling, set the async compilation to the previous state if (s_HasStartedCompiling) { ShaderUtil.allowAsyncCompilation = s_AsyncCompileState; s_HasStartedCompiling = false; } else { s_HasStartedCompiling = true; } } } else { // Check if the user switched off the AOV before the shaders were compiled if (s_HasStartedCompiling) { ShaderUtil.allowAsyncCompilation = s_AsyncCompileState; s_HasStartedCompiling = false; } } HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; if (serializedProperties.aovBitmask.intValue != 0 && hdrp && !hdrp.currentPlatformRenderPipelineSettings.supportRuntimeAOVAPI) { Rect infoRect = rect; // Compute the height of the infobox based on the width of the window and the amount of text GUIStyle.none.CalcMinMaxWidth(new GUIContent(Styles.k_AlphaInfoPost), out float minWidth, out float maxWidth); float lines = Mathf.Max(2, Mathf.CeilToInt(maxWidth / (rect.width - Styles.infoBoxIconWidth))); infoRect.height = lines * CompositorStyle.k_Spacing; EditorGUI.HelpBox(infoRect, Styles.k_AlphaInfoPost, MessageType.Info); rect.y += infoRect.height + EditorGUIUtility.standardVerticalSpacing; } }