protected void DisplayCommonInspector()
        {
            if (FoldableHeader.Begin(this, EditorStrings.DynOcclusion.HeaderUpdateRate))
            {
                updateRate.CustomEnum <DynamicOcclusionUpdateRate>(EditorStrings.DynOcclusion.UpdateRate, EditorStrings.DynOcclusion.UpdateRateDescriptions);

                if (m_Targets.HasAtLeastOneTargetWith((T comp) => { return(comp.updateRate.HasFlag(DynamicOcclusionUpdateRate.EveryXFrames)); }))
                {
                    EditorGUILayout.PropertyField(waitXFrames, EditorStrings.DynOcclusion.WaitXFrames);
                }

                EditorGUILayout.HelpBox(
                    string.Format(EditorStrings.DynOcclusion.GetUpdateRateAdvice <T>(m_Targets[0].updateRate), m_Targets[0].waitXFrames),
                    MessageType.Info);
            }

            FoldableHeader.End();

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.PropertyField(setIsTrigger, EditorStrings.TriggerZone.SetIsTrigger);
            EditorGUILayout.PropertyField(rangeMultiplier, EditorStrings.TriggerZone.RangeMultiplier);

            if (FoldableHeader.Begin(this, EditorStrings.TriggerZone.HeaderInfos))
            {
                EditorGUILayout.HelpBox(EditorStrings.TriggerZone.HelpDescription, MessageType.Info);

                if (m_Targets.HasAtLeastOneTargetWith((VolumetricLightBeam beam) => { return(beam.trackChangesDuringPlaytime); }))
                {
                    EditorGUILayout.HelpBox(EditorStrings.TriggerZone.HelpTrackChangesDuringPlaytimeEnabled, MessageType.Warning);
                }
            }
            FoldableHeader.End();

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            Debug.Assert(m_Targets.Count > 0);

#if DEBUG_SHOW_CUSTOM_MATERIAL_INFO
            if (m_Targets.Count == 1)
            {
                string msg  = "";
                var    geom = m_Targets[0].GetComponentInChildren <BeamGeometry>();
                if (geom == null)
                {
                    msg = "No BeamGeometry";
                }
                else
                {
                    msg = geom._EDITOR_IsUsingCustomMaterial ? "Custom Material" : "GPU Instanced Shared Material";
                }
                EditorGUILayout.HelpBox(msg, MessageType.Info);
            }
#endif

            bool hasLightSpot = false;
            var  light        = m_Targets[0].GetComponent <Light>();
            if (light)
            {
                hasLightSpot = light.type == LightType.Spot;
                if (!hasLightSpot)
                {
                    EditorGUILayout.HelpBox(EditorStrings.Beam.HelpNoSpotlight, MessageType.Warning);
                }
            }

            if (FoldableHeader.Begin(this, EditorStrings.Beam.HeaderBasic))
            {
                // Color
                using (ButtonToggleScopeFromLight(colorFromLight, hasLightSpot))
                {
                    if (!hasLightSpot)
                    {
                        EditorGUILayout.BeginHorizontal();                   // mandatory to have the color picker on the same line (when the button "from light" is not here)
                    }
                    {
                        if (Config.Instance.featureEnabledColorGradient == FeatureEnabledColorGradient.Off)
                        {
                            EditorGUILayout.PropertyField(color, EditorStrings.Beam.ColorMode);
                        }
                        else
                        {
                            EditorGUIUtility.fieldWidth = 65.0f;
                            EditorGUILayout.PropertyField(colorMode, EditorStrings.Beam.ColorMode);
                            EditorGUIUtility.fieldWidth = 0.0f;

                            if (colorMode.enumValueIndex == (int)ColorMode.Gradient)
                            {
                                EditorGUILayout.PropertyField(colorGradient, EditorStrings.Beam.ColorGradient);
                            }
                            else
                            {
                                EditorGUILayout.PropertyField(color, EditorStrings.Beam.ColorFlat);
                            }
                        }
                    }
                    if (!hasLightSpot)
                    {
                        EditorGUILayout.EndHorizontal();
                    }
                }

                // Blending Mode
                EditorGUILayout.PropertyField(blendingMode, EditorStrings.Beam.BlendingMode);

                EditorGUILayout.Separator();

                // Intensity
                bool advancedModeEnabled = false;
                using (ButtonToggleScopeFromLight(intensityFromLight, hasLightSpot))
                {
                    bool advancedModeButton = !hasLightSpot || intensityFromLight.HasAtLeastOneValue(false);
                    using (ButtonToggleScopeAdvanced(intensityModeAdvanced, advancedModeButton))
                    {
                        advancedModeEnabled = intensityModeAdvanced.HasAtLeastOneValue(true);
                        EditorGUILayout.PropertyField(intensityOutside, advancedModeEnabled ? EditorStrings.Beam.IntensityOutside : EditorStrings.Beam.IntensityGlobal);
                    }
                }

                if (advancedModeEnabled)
                {
                    EditorGUILayout.PropertyField(intensityInside, EditorStrings.Beam.IntensityInside);
                }
                else
                {
                    intensityInside.floatValue = intensityOutside.floatValue;
                }

                EditorGUILayout.Separator();

                // Spot Angle
                using (ButtonToggleScopeFromLight(spotAngleFromLight, hasLightSpot))
                {
                    EditorGUILayout.PropertyField(spotAngle, EditorStrings.Beam.SpotAngle);
                }

                PropertyThickness(fresnelPow);

                EditorGUILayout.Separator();

                EditorGUILayout.PropertyField(glareFrontal, EditorStrings.Beam.GlareFrontal);
                EditorGUILayout.PropertyField(glareBehind, EditorStrings.Beam.GlareBehind);

                EditorGUILayout.Separator();

                if (Config.Instance.featureEnabledShaderAccuracyHigh)
                {
                    EditorGUILayout.PropertyField(shaderAccuracy, EditorStrings.Beam.ShaderAccuracy);
                    EditorGUILayout.Separator();
                }

                trackChangesDuringPlaytime.ToggleLeft(EditorStrings.Beam.TrackChanges);
                DrawAnimatorWarning();
            }
            FoldableHeader.End();

            if (FoldableHeader.Begin(this, EditorStrings.Beam.HeaderAttenuation))
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.PropertyField(attenuationEquation, EditorStrings.Beam.AttenuationEquation);
                    if (attenuationEquation.enumValueIndex == (int)AttenuationEquation.Blend)
                    {
                        EditorGUILayout.PropertyField(attenuationCustomBlending, EditorStrings.Beam.AttenuationCustomBlending);
                    }
                }
                EditorGUILayout.EndHorizontal();

                // Fade End
                using (ButtonToggleScopeFromLight(fallOffEndFromLight, hasLightSpot))
                {
                    EditorGUILayout.PropertyField(fallOffEnd, EditorStrings.Beam.FallOffEnd);
                }

                if (fallOffEnd.hasMultipleDifferentValues)
                {
                    EditorGUILayout.PropertyField(fallOffStart, EditorStrings.Beam.FallOffStart);
                }
                else
                {
                    fallOffStart.FloatSlider(EditorStrings.Beam.FallOffStart, 0f, fallOffEnd.floatValue - Consts.FallOffDistancesMinThreshold);
                }

                EditorGUILayout.Separator();

                // Tilt
                EditorGUILayout.PropertyField(tiltFactor, EditorStrings.Beam.TiltFactor);
                GlobalToggle(ref VolumetricLightBeam.editorShowTiltFactor, EditorStrings.Beam.EditorShowTiltDirection, "VLB_BEAM_SHOWTILTDIR");

                if (m_Targets.HasAtLeastOneTargetWith((VolumetricLightBeam beam) => { return(beam.isTilted && beam.shaderAccuracy != ShaderAccuracy.High); }))
                {
                    EditorGUILayout.HelpBox(EditorStrings.Beam.HelpTiltedWithShaderAccuracyFast, MessageType.Warning);
                }
            }
            FoldableHeader.End();

            if (Config.Instance.featureEnabledNoise3D)
            {
                if (FoldableHeader.Begin(this, EditorStrings.Beam.Header3DNoise))
                {
                    noiseMode.CustomEnum <NoiseMode>(EditorStrings.Beam.NoiseMode, EditorStrings.Beam.NoiseModeEnumDescriptions);

                    bool showNoiseProps = m_Targets.HasAtLeastOneTargetWith((VolumetricLightBeam beam) => { return(beam.isNoiseEnabled); });
                    if (showNoiseProps)
                    {
                        EditorGUILayout.PropertyField(noiseIntensity, EditorStrings.Beam.NoiseIntensity);

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            using (new EditorGUI.DisabledGroupScope(noiseScaleUseGlobal.boolValue))
                            {
                                EditorGUILayout.PropertyField(noiseScaleLocal, EditorStrings.Beam.NoiseScale);
                            }
                            noiseScaleUseGlobal.ToggleUseGlobalNoise();
                        }

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            using (new EditorGUI.DisabledGroupScope(noiseVelocityUseGlobal.boolValue))
                            {
                                EditorGUILayout.PropertyField(noiseVelocityLocal, EditorStrings.Beam.NoiseVelocity);
                            }
                            noiseVelocityUseGlobal.ToggleUseGlobalNoise();
                        }

                        ButtonOpenConfig();

                        if (Noise3D.isSupported && !Noise3D.isProperlyLoaded)
                        {
                            EditorGUILayout.HelpBox(EditorStrings.Common.HelpNoiseLoadingFailed, MessageType.Error);
                        }

                        if (!Noise3D.isSupported)
                        {
                            EditorGUILayout.HelpBox(Noise3D.isNotSupportedString, MessageType.Info);
                        }
                    }
                }
                FoldableHeader.End();
            }

            if (FoldableHeader.Begin(this, EditorStrings.Beam.HeaderBlendingDistances))
            {
                {
                    var content = AddEnabledStatusToContentText(EditorStrings.Beam.CameraClippingDistance, cameraClippingDistance);
                    EditorGUILayout.PropertyField(cameraClippingDistance, content);
                }

                {
                    var content = AddEnabledStatusToContentText(EditorStrings.Beam.DepthBlendDistance, depthBlendDistance);
                    EditorGUILayout.PropertyField(depthBlendDistance, content);
                }
            }
            FoldableHeader.End();

            if (FoldableHeader.Begin(this, EditorStrings.Beam.HeaderGeometry))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PropertyField(coneRadiusStart, EditorStrings.Beam.ConeRadiusStart);
                    EditorGUI.BeginChangeCheck();
                    {
                        geomCap.ToggleLeft(EditorStrings.Beam.GeomCap, GUILayout.MaxWidth(40.0f));
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        SetMeshesDirty();
                    }
                }

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(geomMeshType, EditorStrings.Beam.GeomMeshType);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SetMeshesDirty();
                }

                if (geomMeshType.intValue == (int)MeshType.Custom)
                {
                    EditorGUI.indentLevel++;

                    EditorGUI.BeginChangeCheck();
                    {
                        EditorGUILayout.PropertyField(geomCustomSides, EditorStrings.Beam.GeomSides);
                        EditorGUILayout.PropertyField(geomCustomSegments, EditorStrings.Beam.GeomSegments);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        SetMeshesDirty();
                    }

                    if (Config.Instance.featureEnabledMeshSkewing)
                    {
                        var vec3 = skewingLocalForwardDirection.vector3Value;
                        var vec2 = Vector2.zero;
                        EditorGUI.BeginChangeCheck();
                        {
                            vec2 = EditorGUILayout.Vector2Field(EditorStrings.Beam.SkewingLocalForwardDirection, vec3.xy());
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            vec3 = new Vector3(vec2.x, vec2.y, 1.0f);
                            skewingLocalForwardDirection.vector3Value = vec3;
                            SetMeshesDirty();
                        }
                    }

                    EditorGUI.indentLevel--;
                }

                if (m_Targets.Count == 1)
                {
                    EditorGUILayout.HelpBox(m_Targets[0].meshStats, MessageType.Info);
                }

                EditorGUILayout.Separator();

                EditorGUILayout.PropertyField(clippingPlaneTransform, EditorStrings.Beam.ClippingPlane);

                if (m_Targets.HasAtLeastOneTargetWith((VolumetricLightBeam beam) => { return(beam.clippingPlaneTransform != null); }))
                {
                    GlobalToggle(ref VolumetricLightBeam.editorShowClippingPlane, EditorStrings.Beam.EditorShowClippingPlane, "VLB_BEAM_SHOWADDCLIPPINGPLANE");
                }
            }
            FoldableHeader.End();

            if (FoldableHeader.Begin(this, EditorStrings.Beam.HeaderFadeOut))
            {
                bool wasEnabled = fadeOutBegin.floatValue <= fadeOutEnd.floatValue;

                if (m_Targets.HasAtLeastOneTargetWith((VolumetricLightBeam beam) => { return((beam.fadeOutBegin <= beam.fadeOutEnd) != wasEnabled); }))
                {
                    wasEnabled = true;
                    EditorGUI.showMixedValue = true;
                }

                System.Action <float> setFadeOutBegin = value =>
                {
                    fadeOutBegin.floatValue = value;
                    m_Targets.RecordUndoAction("Change Fade Out Begin Distance",
                                               (VolumetricLightBeam beam) => { beam.fadeOutBegin = value; });
                };

                System.Action <float> setFadeOutEnd = value =>
                {
                    fadeOutEnd.floatValue = value;
                    m_Targets.RecordUndoAction("Change Fade Out End Distance",
                                               (VolumetricLightBeam beam) => { beam.fadeOutEnd = value; });
                };

                EditorGUI.BeginChangeCheck();
                bool isEnabled = EditorGUILayout.Toggle(EditorStrings.Beam.FadeOutEnabled, wasEnabled);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    float invValue = isEnabled ? 1 : -1;
                    float valueA   = Mathf.Abs(fadeOutBegin.floatValue);
                    float valueB   = Mathf.Abs(fadeOutEnd.floatValue);
                    setFadeOutBegin(invValue * Mathf.Min(valueA, valueB));
                    setFadeOutEnd(invValue * Mathf.Max(valueA, valueB));
                }

                if (isEnabled)
                {
                    const float kEpsilon = 0.1f;

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(fadeOutBegin, EditorStrings.Beam.FadeOutBegin);
                    if (EditorGUI.EndChangeCheck())
                    {
                        setFadeOutBegin(Mathf.Clamp(fadeOutBegin.floatValue, 0, fadeOutEnd.floatValue - kEpsilon));
                    }

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(fadeOutEnd, EditorStrings.Beam.FadeOutEnd);
                    if (EditorGUI.EndChangeCheck())
                    {
                        setFadeOutEnd(Mathf.Max(fadeOutBegin.floatValue + kEpsilon, fadeOutEnd.floatValue));
                    }

                    if (Application.isPlaying)
                    {
                        if (Config.Instance.fadeOutCameraTransform == null)
                        {
                            EditorGUILayout.HelpBox(EditorStrings.Beam.HelpFadeOutNoMainCamera, MessageType.Error);
                        }
                    }
                }
            }
            FoldableHeader.End();

            if (FoldableHeader.Begin(this, EditorStrings.Beam.Header2D))
            {
                dimensions.CustomEnum <Dimensions>(EditorStrings.Beam.Dimensions, EditorStrings.Common.DimensionsEnumDescriptions);
                DrawSortingLayer();
                DrawSortingOrder();
            }
            FoldableHeader.End();

            if (DrawInfos())
            {
                DrawLineSeparator();
            }

            DrawCustomActionButtons();
            DrawAdditionalFeatures();

            serializedObject.ApplyModifiedProperties();
        }