示例#1
0
            static void DrawerOutputMSAA(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                Rect controlRect = EditorGUILayout.GetControlRect(true);

                EditorGUI.BeginProperty(controlRect, Styles.allowMSAA, p.baseCameraSettings.allowMSAA);
                {
                    using (var checkScope = new EditorGUI.ChangeCheckScope())
                    {
                        int selectedValue = !p.baseCameraSettings.allowMSAA.boolValue ? 0 : 1;
                        var allowMSAA     = EditorGUI.IntPopup(controlRect, Styles.allowMSAA,
                                                               selectedValue, Styles.displayedCameraOptions, Styles.cameraOptions) == 1;
                        if (checkScope.changed)
                        {
                            p.baseCameraSettings.allowMSAA.boolValue = allowMSAA;
                            UpdateStackCamerasOutput(p, camera =>
                            {
                                if (camera.allowMSAA == allowMSAA)
                                {
                                    return(false);
                                }

                                camera.allowMSAA = allowMSAA;
                                return(true);
                            });
                        }
                    }
                }
                EditorGUI.EndProperty();
            }
示例#2
0
            static void DrawerOutputMultiDisplay(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                using (var checkScope = new EditorGUI.ChangeCheckScope())
                {
                    p.baseCameraSettings.DrawMultiDisplay();
                    if (checkScope.changed)
                    {
                        UpdateStackCamerasOutput(p, camera =>
                        {
                            bool isChanged = false;
                            // Force same target display
                            int targetDisplay = p.baseCameraSettings.targetDisplay.intValue;
                            if (camera.targetDisplay != targetDisplay)
                            {
                                camera.targetDisplay = targetDisplay;
                                isChanged            = true;
                            }

                            // Force same target display
                            StereoTargetEyeMask stereoTargetEye = (StereoTargetEyeMask)p.baseCameraSettings.targetEye.intValue;
                            if (camera.stereoTargetEye != stereoTargetEye)
                            {
                                camera.stereoTargetEye = stereoTargetEye;
                                isChanged = true;
                            }

                            return(isChanged);
                        });
                    }
                }
            }
示例#3
0
            static void DrawerOutputTargetTexture(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                var rpAsset = UniversalRenderPipeline.asset;

                using (var checkScope = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUILayout.PropertyField(p.baseCameraSettings.targetTexture, Styles.targetTextureLabel);

                    var texture = p.baseCameraSettings.targetTexture.objectReferenceValue as RenderTexture;
                    if (!p.baseCameraSettings.targetTexture.hasMultipleDifferentValues && rpAsset != null)
                    {
                        int pipelineSamplesCount = rpAsset.msaaSampleCount;

                        if (texture && texture.antiAliasing > pipelineSamplesCount)
                        {
                            string pipelineMSAACaps = (pipelineSamplesCount > 1) ? string.Format(Styles.pipelineMSAACapsSupportSamples, pipelineSamplesCount) : Styles.pipelineMSAACapsDisabled;
                            EditorGUILayout.HelpBox(string.Format(Styles.cameraTargetTextureMSAA, texture.antiAliasing, pipelineMSAACaps), MessageType.Warning, true);
                        }
                    }

                    if (checkScope.changed)
                    {
                        UpdateStackCamerasOutput(p, camera =>
                        {
                            if (camera.targetTexture == texture)
                            {
                                return(false);
                            }

                            camera.targetTexture = texture;
                            return(true);
                        });
                    }
                }
            }
示例#4
0
        void init(List <Object> additionalCameraData)
        {
            if (additionalCameraData == null)
            {
                return;
            }

            m_SerializedCamera = new UniversalRenderPipelineSerializedCamera(new SerializedObject(additionalCameraData.ToArray()));
        }
            static void DrawerRenderingSMAAQuality(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                EditorGUILayout.PropertyField(p.antialiasingQuality, Styles.antialiasingQuality);

                if (CoreEditorUtils.buildTargets.Contains(GraphicsDeviceType.OpenGLES2))
                {
                    EditorGUILayout.HelpBox(Styles.SMAANotSupported, MessageType.Warning);
                }
            }
示例#6
0
        public new void OnEnable()
        {
            base.OnEnable();
            settings.OnEnable();

            m_SerializedCamera = new UniversalRenderPipelineSerializedCamera(serializedObject, settings);

            validCameras.Clear();
            m_TypeErrorCameras.Clear();
            m_OutputWarningCameras.Clear();

            UpdateCameras();
        }
            static void DrawerRenderingAntialiasing(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                Rect antiAliasingRect = EditorGUILayout.GetControlRect();

                EditorGUI.BeginProperty(antiAliasingRect, Styles.antialiasing, p.antialiasing);
                {
                    EditorGUI.BeginChangeCheck();
                    int selectedValue = (int)(AntialiasingMode)EditorGUI.EnumPopup(antiAliasingRect, Styles.antialiasing, (AntialiasingMode)p.antialiasing.intValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        p.antialiasing.intValue = selectedValue;
                    }
                }
                EditorGUI.EndProperty();
            }
示例#8
0
        public new void OnEnable()
        {
            base.OnEnable();
            settings.OnEnable();

            m_SerializedCamera = new UniversalRenderPipelineSerializedCamera(serializedObject);

            m_ErrorIcon   = LoadConsoleIcon(true);
            m_WarningIcon = LoadConsoleIcon(false);
            validCameras.Clear();
            m_TypeErrorCameras.Clear();
            m_OutputWarningCameras.Clear();

            UpdateCameras();
        }
            static void Drawer_Environment_VolumeTrigger(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                var controlRect = EditorGUILayout.GetControlRect(true);

                EditorGUI.BeginProperty(controlRect, Styles.volumeTrigger, p.volumeTrigger);
                {
                    EditorGUI.BeginChangeCheck();
                    var newValue = EditorGUI.ObjectField(controlRect, Styles.volumeTrigger, (Transform)p.volumeTrigger.objectReferenceValue, typeof(Transform), true);
                    if (EditorGUI.EndChangeCheck() && !Equals(p.volumeTrigger.objectReferenceValue, newValue))
                    {
                        p.volumeTrigger.objectReferenceValue = newValue;
                    }
                }
                EditorGUI.EndProperty();
            }
            static void Drawer_Environment_VolumeUpdate(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                EditorGUI.BeginChangeCheck();
                VolumeFrameworkUpdateMode prevVolumeUpdateMode = (VolumeFrameworkUpdateMode)p.volumeFrameworkUpdateMode.intValue;

                EditorGUILayout.PropertyField(p.volumeFrameworkUpdateMode, Styles.volumeUpdates);
                if (EditorGUI.EndChangeCheck())
                {
                    if (p.serializedObject.targetObject is not Camera cam)
                    {
                        return;
                    }

                    VolumeFrameworkUpdateMode curVolumeUpdateMode = (VolumeFrameworkUpdateMode)p.volumeFrameworkUpdateMode.intValue;
                    cam.SetVolumeFrameworkUpdateMode(curVolumeUpdateMode);
                }
            }
            static void Drawer_Environment_ClearFlags(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                EditorGUI.showMixedValue = p.baseCameraSettings.clearFlags.hasMultipleDifferentValues;

                Rect clearFlagsRect = EditorGUILayout.GetControlRect();

                EditorGUI.BeginProperty(clearFlagsRect, Styles.backgroundType, p.baseCameraSettings.clearFlags);
                {
                    EditorGUI.BeginChangeCheck();
                    BackgroundType backgroundType = GetBackgroundType((CameraClearFlags)p.baseCameraSettings.clearFlags.intValue);
                    var            selectedValue  = (BackgroundType)EditorGUI.EnumPopup(clearFlagsRect, Styles.backgroundType, backgroundType);
                    if (EditorGUI.EndChangeCheck())
                    {
                        CameraClearFlags selectedClearFlags;
                        switch (selectedValue)
                        {
                        case BackgroundType.Skybox:
                            selectedClearFlags = CameraClearFlags.Skybox;
                            break;

                        case BackgroundType.DontCare:
                            selectedClearFlags = CameraClearFlags.Nothing;
                            break;

                        default:
                            selectedClearFlags = CameraClearFlags.SolidColor;
                            break;
                        }

                        p.baseCameraSettings.clearFlags.intValue = (int)selectedClearFlags;
                    }

                    if (!p.baseCameraSettings.clearFlags.hasMultipleDifferentValues)
                    {
                        if (GetBackgroundType((CameraClearFlags)p.baseCameraSettings.clearFlags.intValue) == BackgroundType.SolidColor)
                        {
                            using (var group = new EditorGUI.IndentLevelScope())
                            {
                                p.baseCameraSettings.DrawBackgroundColor();
                            }
                        }
                    }
                }
                EditorGUI.EndProperty();
                EditorGUI.showMixedValue = false;
            }
示例#12
0
            static void DrawerOutputXRRendering(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                Rect controlRect = EditorGUILayout.GetControlRect(true);

                EditorGUI.BeginProperty(controlRect, Styles.xrTargetEye, p.allowXRRendering);
                {
                    using (var checkScope = new EditorGUI.ChangeCheckScope())
                    {
                        int  selectedValue    = !p.allowXRRendering.boolValue ? 0 : 1;
                        bool allowXRRendering = EditorGUI.IntPopup(controlRect, Styles.xrTargetEye, selectedValue, Styles.xrTargetEyeOptions, Styles.xrTargetEyeValues) == 1;
                        if (checkScope.changed)
                        {
                            p.allowXRRendering.boolValue = allowXRRendering;
                        }
                    }
                }
                EditorGUI.EndProperty();
            }
示例#13
0
            static void UpdateStackCamerasOutput(UniversalRenderPipelineSerializedCamera p, Func <Camera, bool> updateOutputProperty)
            {
                int cameraCount = p.cameras.arraySize;

                for (int i = 0; i < cameraCount; ++i)
                {
                    SerializedProperty cameraProperty = p.cameras.GetArrayElementAtIndex(i);
                    Camera             overlayCamera  = cameraProperty.objectReferenceValue as Camera;
                    if (overlayCamera != null)
                    {
                        Undo.RecordObject(overlayCamera, Styles.inspectorOverlayCameraText);
                        if (updateOutputProperty(overlayCamera))
                        {
                            EditorUtility.SetDirty(overlayCamera);
                        }
                    }
                }
            }
示例#14
0
            static void DrawerOutputNormalizedViewPort(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                using (var checkScope = new EditorGUI.ChangeCheckScope())
                {
                    CameraUI.Output.Drawer_Output_NormalizedViewPort(p, owner);
                    if (checkScope.changed)
                    {
                        UpdateStackCamerasOutput(p, camera =>
                        {
                            Rect rect = p.baseCameraSettings.normalizedViewPortRect.rectValue;
                            if (camera.rect != rect)
                            {
                                camera.rect = p.baseCameraSettings.normalizedViewPortRect.rectValue;
                                return(true);
                            }

                            return(false);
                        });
                    }
                }
            }
            static bool IsAnyRendererHasPostProcessingEnabled(UniversalRenderPipelineSerializedCamera p, UniversalRenderPipelineAsset rpAsset)
            {
                int selectedRendererOption = p.renderer.intValue;

                if (selectedRendererOption < -1 || selectedRendererOption > rpAsset.m_RendererDataList.Length || p.renderer.hasMultipleDifferentValues)
                {
                    return(false);
                }

                var rendererData = selectedRendererOption == -1 ? rpAsset.m_RendererData : rpAsset.m_RendererDataList[selectedRendererOption];

                var forwardRendererData = rendererData as UniversalRendererData;

                if (forwardRendererData != null && forwardRendererData.postProcessData == null)
                {
                    return(true);
                }

                var renderer2DData = rendererData as UnityEngine.Rendering.Universal.Renderer2DData;

                return(renderer2DData != null && renderer2DData.postProcessData == null);
            }
        public new void OnEnable()
        {
            base.OnEnable();
            settings.OnEnable();

            m_SerializedCamera = new UniversalRenderPipelineSerializedCamera(serializedObject);

            m_CommonCameraSettingsFoldout = new SavedBool($"{target.GetType()}.CommonCameraSettingsFoldout", false);
            m_EnvironmentSettingsFoldout  = new SavedBool($"{target.GetType()}.EnvironmentSettingsFoldout", false);
            m_OutputSettingsFoldout       = new SavedBool($"{target.GetType()}.OutputSettingsFoldout", false);
            m_RenderingSettingsFoldout    = new SavedBool($"{target.GetType()}.RenderingSettingsFoldout", false);
            m_StackSettingsFoldout        = new SavedBool($"{target.GetType()}.StackSettingsFoldout", false);

            m_ErrorIcon   = LoadConsoleIcon(true);
            m_WarningIcon = LoadConsoleIcon(false);
            validCameras.Clear();
            m_TypeErrorCameras.Clear();
            m_OutputWarningCameras.Clear();

            UpdateAnimationValues(true);

            UpdateCameras();
        }
            static void DrawerRenderingRenderer(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                var rpAsset = UniversalRenderPipeline.asset;

                int selectedRendererOption = p.renderer.intValue;

                EditorGUI.BeginChangeCheck();

                Rect controlRect = EditorGUILayout.GetControlRect(true);

                EditorGUI.BeginProperty(controlRect, Styles.rendererType, p.renderer);

                EditorGUI.showMixedValue = p.renderer.hasMultipleDifferentValues;
                int selectedRenderer = EditorGUI.IntPopup(controlRect, Styles.rendererType, selectedRendererOption, rpAsset.rendererDisplayList, rpAsset.rendererIndexList);

                EditorGUI.EndProperty();
                if (!rpAsset.ValidateRendererDataList())
                {
                    EditorGUILayout.HelpBox(Styles.noRendererError, MessageType.Error);
                }
                else if (!rpAsset.ValidateRendererData(selectedRendererOption))
                {
                    EditorGUILayout.HelpBox(Styles.missingRendererWarning, MessageType.Warning);
                    var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
                    if (GUI.Button(rect, Styles.selectRenderPipelineAsset))
                    {
                        Selection.activeObject = AssetDatabase.LoadAssetAtPath <UniversalRenderPipelineAsset>(AssetDatabase.GetAssetPath(UniversalRenderPipeline.asset));
                    }
                    GUILayout.Space(5);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    p.renderer.intValue = selectedRenderer;
                }
            }
示例#18
0
            static void DrawerOutputAllowDynamicResolution(UniversalRenderPipelineSerializedCamera p, Editor owner)
            {
                using (var checkScope = new EditorGUI.ChangeCheckScope())
                {
                    CameraUI.Output.Drawer_Output_AllowDynamicResolution(p, owner);
                    if (checkScope.changed)
                    {
                        UpdateStackCamerasOutput(p, camera =>
                        {
                            bool allowDynamicResolution = p.allowDynamicResolution.boolValue;

                            if (camera.allowDynamicResolution == p.allowDynamicResolution.boolValue)
                            {
                                return(false);
                            }

                            EditorUtility.SetDirty(camera);

                            camera.allowDynamicResolution = allowDynamicResolution;
                            return(true);
                        });
                    }
                }
            }
示例#19
0
        private void UpdateStackCameraOutput(Camera cam, UniversalRenderPipelineSerializedCamera serializedCamera)
        {
            if ((CameraRenderType)serializedCamera.cameraType.intValue == CameraRenderType.Base)
            {
                return;
            }

            serializedCamera.Update();
            Undo.RecordObject(camera, Styles.inspectorOverlayCameraText);

            var serializedCameraSettings = serializedCamera.baseCameraSettings;

            bool isChanged = false;

            // Force same render texture
            RenderTexture targetTexture = settings.targetTexture.objectReferenceValue as RenderTexture;

            if (cam.targetTexture != targetTexture)
            {
                cam.targetTexture = targetTexture;
                isChanged         = true;
            }

            // Force same hdr
            bool allowHDR = settings.HDR.boolValue;

            if (cam.allowHDR != allowHDR)
            {
                cam.allowHDR = allowHDR;
                isChanged    = true;
            }

            // Force same mssa
            bool allowMSSA = settings.allowMSAA.boolValue;

            if (cam.allowMSAA != allowMSSA)
            {
                cam.allowMSAA = allowMSSA;
                isChanged     = true;
            }

            // Force same viewport rect
            Rect rect = settings.normalizedViewPortRect.rectValue;

            if (cam.rect != rect)
            {
                cam.rect  = settings.normalizedViewPortRect.rectValue;
                isChanged = true;
            }

            // Force same dynamic resolution
            bool allowDynamicResolution = settings.allowDynamicResolution.boolValue;

            if (serializedCamera.allowDynamicResolution.boolValue != allowDynamicResolution)
            {
                cam.allowDynamicResolution = allowDynamicResolution;
                isChanged = true;
            }

            // Force same target display
            int targetDisplay = settings.targetDisplay.intValue;

            if (cam.targetDisplay != targetDisplay)
            {
                cam.targetDisplay = targetDisplay;
                isChanged         = true;
            }

#if ENABLE_VR && ENABLE_XR_MODULE
            // Force same target display
            int selectedValue = !m_SerializedCamera.allowXRRendering.boolValue ? 0 : 1;
            int overlayCameraSelectedValue = !serializedCamera.allowXRRendering.boolValue ? 0 : 1;
            if (overlayCameraSelectedValue != selectedValue)
            {
                serializedCamera.allowXRRendering.boolValue = selectedValue == 1;
                isChanged = true;
            }
#endif

            if (isChanged)
            {
                EditorUtility.SetDirty(cam);
                serializedCamera.Apply();
            }
        }
示例#20
0
        private bool IsStackCameraOutputDirty(Camera cam, UniversalRenderPipelineSerializedCamera serializedCamera)
        {
            serializedCamera.Update();

            // Force same render texture
            RenderTexture targetTexture = settings.targetTexture.objectReferenceValue as RenderTexture;

            if (cam.targetTexture != targetTexture)
            {
                return(true);
            }

            // Force same hdr
            bool allowHDR = settings.HDR.boolValue;

            if (cam.allowHDR != allowHDR)
            {
                return(true);
            }

            // Force same mssa
            bool allowMSSA = settings.allowMSAA.boolValue;

            if (cam.allowMSAA != allowMSSA)
            {
                return(true);
            }

            // Force same viewport rect
            Rect rect = settings.normalizedViewPortRect.rectValue;

            if (cam.rect != rect)
            {
                return(true);
            }

            // Force same dynamic resolution
            bool allowDynamicResolution = settings.allowDynamicResolution.boolValue;

            if (serializedCamera.allowDynamicResolution.boolValue != allowDynamicResolution)
            {
                return(true);
            }

            // Force same target display
            int targetDisplay = settings.targetDisplay.intValue;

            if (cam.targetDisplay != targetDisplay)
            {
                return(true);
            }

#if ENABLE_VR && ENABLE_XR_MODULE
            // Force same target display
            int selectedValue = !m_SerializedCamera.allowXRRendering.boolValue ? 0 : 1;
            int overlayCameraSelectedValue = !serializedCamera.allowXRRendering.boolValue ? 0 : 1;
            if (overlayCameraSelectedValue != selectedValue)
            {
                return(true);
            }
#endif

            return(false);
        }
 static void DrawerRenderingClearDepth(UniversalRenderPipelineSerializedCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.clearDepth, Styles.clearDepth);
 }
 static void DrawerRenderingOpaqueTexture(UniversalRenderPipelineSerializedCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.renderOpaque, Styles.requireOpaqueTexture);
 }
 static void DrawerRenderingPriority(UniversalRenderPipelineSerializedCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.depth, Styles.priority);
 }
 static void DrawerRenderingRenderPostProcessing(UniversalRenderPipelineSerializedCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.renderPostProcessing, Styles.renderPostProcessing);
 }
 static void DrawerRenderingRenderShadows(UniversalRenderPipelineSerializedCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.renderShadows, Styles.renderingShadows);
 }