Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        //Header
        Texture2D headerImage = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Scripts/RenderPipeline/Sources/Textures/MobileBaseSRP_Header.psd", typeof(Texture2D));

        headerContent = new GUIContent(headerImage);

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(headerContent, GUILayout.MaxHeight(30f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.LabelField(headerVersion, EditorStyles.miniLabel);
        GUILayout.EndHorizontal();


        //Common Setup Block
        CustomUi.GuiLineSeparator(1);
        commonPipelineProps = CustomUi.FoldOut("Common Pipeline properties", commonPipelineProps);
        EditorGUILayout.Separator();

        if (commonPipelineProps)
        {
            shaderErrorMaterial     = serializedObject.FindProperty("ShaderErrorMaterial");
            useLinearLightIntensity = serializedObject.FindProperty("UseLinearLightIntensity");
            defaultMaterialOverride = serializedObject.FindProperty("defaultMaterialOverride");

            //Shader Error material field
            EditorGUILayout.ObjectField(shaderErrorMaterial);
            if (shaderErrorMaterial.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Warning: Shader Error material is not assigned. Please assign one!", MessageType.Warning);
            }

            EditorGUILayout.ObjectField(defaultMaterialOverride);
            if (defaultMaterialOverride.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Warning: Default Unlit material is not assigned. Please assign one!", MessageType.Warning);
            }
            serializedObject.ApplyModifiedProperties();

            //Light Attenuation type selector
            lightColorSpaceEnums = (LightColorSpace)EditorGUILayout.EnumPopup("Light Attenuation Formule:", lightColorSpaceEnums);
            ChangeLightAttenuationType(lightColorSpaceEnums);
        }

        //Batching Setup Block
        CustomUi.GuiLineSeparator(2);
        batchingProps = CustomUi.FoldOut("Batching Settings", batchingProps);
        EditorGUILayout.Separator();
        if (batchingProps)
        {
            gpuInstancing     = serializedObject.FindProperty("GpuInstancing");
            inDynamicBatching = serializedObject.FindProperty("InDynamicBatching");
            batchingTypeEnums = (BatchingType)EditorGUILayout.EnumPopup("Batching Type:", batchingTypeEnums);
            ChangeBatchingType(batchingTypeEnums);
        }

        //Render Target Setup Block
        CustomUi.GuiLineSeparator(2);
        renderTargetProps = CustomUi.FoldOut("Render Target Properties", renderTargetProps);
        EditorGUILayout.Separator();

        if (renderTargetProps)
        {
            renderMesh     = serializedObject.FindProperty("RenderMesh");
            renderMaterial = serializedObject.FindProperty("RenderMaterial");
            EditorGUILayout.ObjectField(renderMesh, meshTargetContent);
            if (renderMesh.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Warning: Target mesh filter is not assigned. Please assign one!", MessageType.Warning);
            }
            EditorGUILayout.ObjectField(renderMaterial, renderMaterialContent);
            if (renderMaterial.objectReferenceValue == null)
            {
                renderMaterial.objectReferenceValue = new Material(Shader.Find("Hidden/CameraBlit"));
                EditorGUILayout.HelpBox("Warning: Render material is not assigned. Please assign one!", MessageType.Warning);
            }
            serializedObject.ApplyModifiedProperties();
        }

        //Postprocessing Settings Block
        CustomUi.GuiLineSeparator(2);
        postprocessingPorps = CustomUi.FoldOut("Postprocessing", postprocessingPorps);
        EditorGUILayout.Separator();
        if (postprocessingPorps)
        {
            //Usage tip
            EditorGUILayout.HelpBox("Create PostProcessing preset and assign it to scenes PostProcess controller", MessageType.Info);

            //Global toggles
            CustomUi.GuiLineSeparator(1);

            useBloom               = serializedObject.FindProperty("UseGlobalBloom");
            useFishEye             = serializedObject.FindProperty("UseGlobalFishEye");
            useVignetting          = serializedObject.FindProperty("UseGlobalVignetting");
            useLut                 = serializedObject.FindProperty("UseGlobalLut");
            useChromaticAberration = serializedObject.FindProperty("UseChromaticAberration");

            EditorGUILayout.LabelField(postGlobalTogglesLableContent, EditorStyles.boldLabel);
            useBloom.boolValue               = EditorGUILayout.Toggle(useBloomContent, useBloom.boolValue);
            useFishEye.boolValue             = EditorGUILayout.Toggle(useFishEyeContent, useFishEye.boolValue);
            useVignetting.boolValue          = EditorGUILayout.Toggle(useVignettingContent, useVignetting.boolValue);
            useChromaticAberration.boolValue = EditorGUILayout.Toggle(useChromaticAberrationContent, useChromaticAberration.boolValue);
            useLut.boolValue = EditorGUILayout.Toggle(useLutContent, useLut.boolValue);

            CustomUi.GuiLineSeparator(1);

            defaultPostPreset = serializedObject.FindProperty("DefaultPostPreset");
            EditorGUILayout.ObjectField(defaultPostPreset, defaultPostPresetContent);

            CustomUi.GuiLineSeparator(1);

            EditorGUILayout.LabelField(subResLableContent, EditorStyles.boldLabel);
            downScaleValue   = serializedObject.FindProperty("DownScaleValue");
            useSubResolution = EditorGUILayout.Toggle(useSubResContent, useSubResolution);
            if (useSubResolution)
            {
                EditorGUILayout.IntSlider(downScaleValue, 1, 10, resolutionDownscaleContent);
            }
            else
            {
                downScaleValue.intValue = 1;
            }

            CustomUi.GuiLineSeparator(1);

            EditorGUILayout.LabelField(blurFiltering, EditorStyles.boldLabel);
            dualFiltering  = serializedObject.FindProperty("DualFiltering");
            blurOffsetDown = serializedObject.FindProperty("BlurOffsetDown");
            blurOffsetUp   = serializedObject.FindProperty("BlurOffsetUp");
            bluumPasses    = serializedObject.FindProperty("BloomPasses");
            EditorGUILayout.ObjectField(dualFiltering, dualMaterialContent);
            EditorGUILayout.Slider(blurOffsetDown, 0f, 10f, blurOffsetDownContent);
            EditorGUILayout.Slider(blurOffsetUp, 0f, 10f, blurOffsetUpContent);
            EditorGUILayout.IntSlider(bluumPasses, 3, 10, bluumPassesContent);

            serializedObject.ApplyModifiedProperties();
        }
        //CustomUI.GuiLineSeparator(10);
        //base.OnInspectorGUI();
    }
    public override void OnInspectorGUI()
    {
        //Header
        Texture2D headerImage = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/Scripts/RenderPipeline/Sources/Textures/MobileBaseSRP_Header.psd", typeof(Texture2D));

        headerContent = new GUIContent(headerImage);

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(headerContent, GUILayout.MaxHeight(30f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField(headerHeaderName, EditorStyles.boldLabel);

        //Vignetting Foldout
        CustomUi.GuiLineSeparator(1);
        vignettingFoldout = CustomUi.FoldOut("Vignetting", vignettingFoldout);
        EditorGUILayout.Separator();
        if (vignettingFoldout)
        {
            useVignetting      = serializedObject.FindProperty("UseVignetting");
            vignettingColor    = serializedObject.FindProperty("VignettingColor");
            vignettingSize     = serializedObject.FindProperty("VignettingSize");
            vignettingContrast = serializedObject.FindProperty("VignettingContrast");

            useVignetting.boolValue = EditorGUILayout.Toggle(useVignettingContent, useVignetting.boolValue);
            if (useVignetting.boolValue)
            {
                vignettingColor.colorValue    = EditorGUILayout.ColorField(vignettingColorContent, vignettingColor.colorValue);
                vignettingSize.floatValue     = EditorGUILayout.FloatField(vignettingSizeContent, vignettingSize.floatValue);
                vignettingContrast.floatValue = EditorGUILayout.FloatField(vignettingContrastContent, vignettingContrast.floatValue);
            }
            serializedObject.ApplyModifiedProperties();
        }

        //LUT Foldout
        CustomUi.GuiLineSeparator(2);
        lutFoldout = CustomUi.FoldOut("LUT Grading", lutFoldout);
        EditorGUILayout.Separator();
        if (lutFoldout)
        {
            useLutGrading = serializedObject.FindProperty("UseLUTGrading");
            lutTex        = serializedObject.FindProperty("LUTTex");
            lutPower      = serializedObject.FindProperty("LUTPower");

            useLutGrading.boolValue = EditorGUILayout.Toggle(useLutContent, useLutGrading.boolValue);
            if (useLutGrading.boolValue)
            {
                EditorGUILayout.ObjectField(lutTex, lutTexContent);
                EditorGUILayout.Slider(lutPower, 0.0f, 1.0f, lutPowerContent);
            }
            serializedObject.ApplyModifiedProperties();
        }

        //FishEye Foldout
        CustomUi.GuiLineSeparator(2);
        fishEyeFoldout = CustomUi.FoldOut("FishEye Distortion", fishEyeFoldout);
        EditorGUILayout.Separator();
        if (fishEyeFoldout)
        {
            fishEyePower = serializedObject.FindProperty("FishEyePower");

            useFishEye = EditorGUILayout.Toggle(useFishEyeContent, useFishEye);
            if (useFishEye)
            {
                fishEyeType = (FishEyeType)EditorGUILayout.EnumPopup("FishEye Type:", fishEyeType);
                EditorGUILayout.Slider(fishEyePower, -1.0f, 2.0f, fishEyePowerContent);
            }
            ChangeFishEyeType(fishEyeType);
            serializedObject.ApplyModifiedProperties();
        }

        //Bloom Foldout
        CustomUi.GuiLineSeparator(2);
        bloomFoldout = CustomUi.FoldOut("Bloom", bloomFoldout);
        EditorGUILayout.Separator();
        if (bloomFoldout)
        {
            useBloom       = serializedObject.FindProperty("UseBloom");
            bloomIntensity = serializedObject.FindProperty("BloomIntensity");

            useBloom.boolValue = EditorGUILayout.Toggle(useBloomContent, useBloom.boolValue);
            if (useBloom.boolValue)
            {
                EditorGUILayout.Slider(bloomIntensity, 0.0f, 5.0f, bloomIntensityContent);
            }
            serializedObject.ApplyModifiedProperties();
        }

        //Chromatic Aberration Foldout
        CustomUi.GuiLineSeparator(2);
        chromaticAberrationFoldout = CustomUi.FoldOut("Chromatic Aberration", chromaticAberrationFoldout);
        EditorGUILayout.Separator();
        if (chromaticAberrationFoldout)
        {
            useChromaticAberration    = serializedObject.FindProperty("UseChromaticAberration");
            chromaticAberrationOffset = serializedObject.FindProperty("ChromaticAberrationOffset");
            chromaticAberrationRadius = serializedObject.FindProperty("ChromaticAberrationRadius");

            useChromaticAberration.boolValue = EditorGUILayout.Toggle(useChromaticAberrationContent, useChromaticAberration.boolValue);
            if (useChromaticAberration.boolValue)
            {
                EditorGUILayout.Slider(chromaticAberrationOffset, 0.001f, 0.1f, chromaticAberrationOffsetContent);
                EditorGUILayout.Slider(chromaticAberrationRadius, 0.0f, 1.0f, chromaticAberrationRadiusContent);
            }
            serializedObject.ApplyModifiedProperties();
        }

        //Usage Tip
        EditorGUILayout.Separator();
        EditorGUILayout.HelpBox("To use this Preset in your scene, please add 'MSRP PostProcess Controller' to any object on the scene and assign this preset into it", MessageType.None);


        //CustomUI.GuiLineSeparator(10);
        //base.OnInspectorGUI();
    }