Exemplo n.º 1
0
        static void GenerateFrameSettingsPanel(string menuName, FrameSettingsHistory frameSettings)
        {
            HDRenderPipelineAsset defaultHdrpAsset = HDRenderPipeline.defaultAsset;
            var camera = frameSettings.camera;
            List <DebugUI.Widget> widgets = new List <DebugUI.Widget>();

            widgets.AddRange(GenerateFrameSettingsPanelContent(defaultHdrpAsset, ref frameSettings));
            var panel = DebugManager.instance.GetPanel(menuName, true, 1);

            panel.children.Add(widgets.ToArray());
        }
Exemplo n.º 2
0
        // Note: this version is the one tested as there is issue getting HDRenderPipelineAsset in batchmode in unit test framework currently.
        /// <summary>Same than FrameSettings.AggregateFrameSettings but keep history of agregation in a collection for DebugMenu.
        /// Aggregation is default with override of the renderer then sanitazed depending on supported features of hdrpasset. Then the DebugMenu override occurs.</summary>
        /// <param name="aggregatedFrameSettings">The aggregated FrameSettings result.</param>
        /// <param name="camera">The camera rendering.</param>
        /// <param name="additionalData">Additional data of the camera rendering.</param>
        /// <param name="defaultFrameSettings">Base framesettings to copy prior any override.</param>
        /// <param name="supportedFeatures">Currently supported feature for the sanitazation pass.</param>
        public static void AggregateFrameSettings(ref FrameSettings aggregatedFrameSettings, Camera camera, HDAdditionalCameraData additionalData, ref FrameSettings defaultFrameSettings, RenderPipelineSettings supportedFeatures)
        {
            FrameSettingsHistory history = new FrameSettingsHistory
            {
                camera      = camera,
                defaultType = additionalData ? additionalData.defaultFrameSettings : FrameSettingsRenderType.Camera
            };

            aggregatedFrameSettings = defaultFrameSettings;
            if (additionalData && additionalData.customRenderingSettings)
            {
                FrameSettings.Override(ref aggregatedFrameSettings, additionalData.renderingPathCustomFrameSettings, additionalData.renderingPathCustomFrameSettingsOverrideMask);
                history.customMask = additionalData.renderingPathCustomFrameSettingsOverrideMask;
            }
            history.overridden = aggregatedFrameSettings;
            FrameSettings.Sanitize(ref aggregatedFrameSettings, camera, supportedFeatures);

            bool noHistory        = !frameSettingsHistory.ContainsKey(camera);
            bool updatedComponent = !noHistory && frameSettingsHistory[camera].sanitazed != aggregatedFrameSettings;
            bool dirty            = noHistory || updatedComponent;

            history.sanitazed = aggregatedFrameSettings;
            if (dirty)
            {
                history.debug = history.sanitazed;
            }
            else
            {
                history.debug = frameSettingsHistory[camera].debug;

                // Ensure user is not trying to activate unsupported settings in DebugMenu
                FrameSettings.Sanitize(ref history.debug, camera, supportedFeatures);
            }

            aggregatedFrameSettings      = history.debug;
            frameSettingsHistory[camera] = history;
        }
Exemplo n.º 3
0
        static DebugUI.Widget[] GenerateFrameSettingsPanelContent(HDRenderPipelineAsset defaultHdrpAsset, ref FrameSettingsHistory frameSettings)
        {
            var panelContent = new DebugUI.Widget[foldoutNames.Length];

            for (int index = 0; index < foldoutNames.Length; ++index)
            {
                panelContent[index] = new DebugUI.Foldout(foldoutNames[index], GenerateHistoryArea(defaultHdrpAsset, ref frameSettings, index), columnNames);
            }
            return(panelContent);
        }
Exemplo n.º 4
0
        static ObservableList <DebugUI.Widget> GenerateHistoryArea(HDRenderPipelineAsset defaultHdrpAsset, ref FrameSettingsHistory frameSettings, int groupIndex)
        {
            if (!attributesGroup.ContainsKey(groupIndex) || attributesGroup[groupIndex] == null)
            {
                attributesGroup[groupIndex] = attributes?.Where(pair => pair.Value?.group == groupIndex)?.OrderBy(pair => pair.Value.orderInGroup);
            }
            if (!attributesGroup.ContainsKey(groupIndex))
            {
                throw new ArgumentException("Unknown groupIndex");
            }

            var area = new ObservableList <DebugUI.Widget>();

            foreach (var field in attributesGroup[groupIndex])
            {
                switch (field.Value.type)
                {
                case FrameSettingsFieldAttribute.DisplayType.BoolAsCheckbox:
                    area.Add(GenerateHistoryBoolField(defaultHdrpAsset, ref frameSettings, field.Key, field.Value));
                    break;

                case FrameSettingsFieldAttribute.DisplayType.BoolAsEnumPopup:
                    area.Add(GenerateHistoryEnumField(
                                 defaultHdrpAsset,
                                 ref frameSettings,
                                 field.Key,
                                 field.Value,
                                 RetrieveEnumTypeByField(field.Key)
                                 ));
                    break;

                case FrameSettingsFieldAttribute.DisplayType.Others:     // for now, skip other display settings. Add them if needed
                    break;
                }
            }
            return(area);
        }
Exemplo n.º 5
0
        static DebugUI.HistoryEnumField GenerateHistoryEnumField(HDRenderPipelineAsset defaultHdrpAsset, ref FrameSettingsHistory frameSettings, FrameSettingsField field, FrameSettingsFieldAttribute attribute, Type autoEnum)
        {
            Camera camera        = frameSettings.camera;
            var    renderType    = frameSettings.defaultType;
            string displayIndent = "";

            for (int indent = 0; indent < attribute.indentLevel; ++indent)
            {
                displayIndent += "  ";
            }
            return(new DebugUI.HistoryEnumField
            {
                displayName = displayIndent + attribute.displayedName,
                getter = () => frameSettingsHistory[camera].debug.IsEnabled(field) ? 1 : 0,
                setter = value =>
                {
                    var tmp = frameSettingsHistory[camera]; //indexer with struct will create a copy
                    tmp.debug.SetEnabled(field, value == 1);
                    frameSettingsHistory[camera] = tmp;
                },
                autoEnum = autoEnum,

                // Contrarily to other enum of DebugMenu, we do not need to stock index as
                // it can be computed again with data in the dedicated debug section of history
                getIndex = () => frameSettingsHistory[camera].debug.IsEnabled(field) ? 1 : 0,
                setIndex = (int a) => { },

                historyIndexGetter = new Func <int>[]
                {
                    () => frameSettingsHistory[camera].sanitazed.IsEnabled(field) ? 1 : 0,
                    () => frameSettingsHistory[camera].overridden.IsEnabled(field) ? 1 : 0,
                    () => defaultHdrpAsset.GetDefaultFrameSettings(renderType).IsEnabled(field) ? 1 : 0
                }
            });
        }
Exemplo n.º 6
0
        static DebugUI.HistoryBoolField GenerateHistoryBoolField(HDRenderPipelineAsset defaultHdrpAsset, ref FrameSettingsHistory frameSettings, FrameSettingsField field, FrameSettingsFieldAttribute attribute)
        {
            Camera camera        = frameSettings.camera;
            var    renderType    = frameSettings.defaultType;
            string displayIndent = "";

            for (int indent = 0; indent < attribute.indentLevel; ++indent)
            {
                displayIndent += "  ";
            }
            return(new DebugUI.HistoryBoolField
            {
                displayName = displayIndent + attribute.displayedName,
                getter = () => frameSettingsHistory[camera].debug.IsEnabled(field),
                setter = value =>
                {
                    var tmp = frameSettingsHistory[camera]; //indexer with struct will create a copy
                    tmp.debug.SetEnabled(field, value);
                    frameSettingsHistory[camera] = tmp;
                },
                historyGetter = new Func <bool>[]
                {
                    () => frameSettingsHistory[camera].sanitazed.IsEnabled(field),
                    () => frameSettingsHistory[camera].overridden.IsEnabled(field),
                    () => defaultHdrpAsset.GetDefaultFrameSettings(renderType).IsEnabled(field)
                }
            });
        }