public override void OnEnable()
        {
            base.OnEnable();

            headerTex = Resources.Load <Texture2D>("beautifyHeader");
            blackBack = new GUIStyle();
            blackBack.normal.background = MakeTex(4, 4, Color.black);

            beautify = (Beautify)target;

            propertyFetcher = new PropertyFetcher <Beautify>(serializedObject);

            // get volume fx settings
            var settings = beautify.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                           .Where(t => t.FieldType.IsSubclassOf(typeof(VolumeParameter)))
                           .Where(t => (t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0) ||
                                  (t.GetCustomAttributes(typeof(SerializeField), false).Length > 0))
                           .Where(t => t.GetCustomAttributes(typeof(HideInInspector), false).Length == 0)
                           .Where(t => t.GetCustomAttributes(typeof(Beautify.SectionGroup), false).Any());

            // group by settings first
            foreach (var setting in settings)
            {
                SectionContents sectionContents = null;

                foreach (var section in setting.GetCustomAttributes(typeof(Beautify.SectionGroup)) as IEnumerable <Beautify.SectionGroup> )
                {
                    if (!sections.TryGetValue(section, out sectionContents))
                    {
                        sectionContents = sections[section] = new SectionContents();
                    }

                    bool isGrouped = false;
                    foreach (var settingGroup in setting.GetCustomAttributes(typeof(Beautify.SettingsGroup)) as IEnumerable <Beautify.SettingsGroup> )
                    {
                        if (!groupedFields.ContainsKey(settingGroup))
                        {
                            sectionContents.groups[settingGroup] = groupedFields[settingGroup] = new List <MemberInfo>();
                        }
                        groupedFields[settingGroup].Add(setting);
                        isGrouped = true;
                    }

                    if (!isGrouped)
                    {
                        sectionContents.singleFields.Add(setting);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void ManageBuildOptimizationStatus(bool force)
        {
            Beautify beautify = sharedSettings;

            if (beautify == null)
            {
                return;
            }

            if (!beautify.active && (wasBuildOptActive || force))
            {
                StripBeautifyKeywords();
            }
            else if (beautify.active && (!wasBuildOptActive || force))
            {
                SetStripShaderKeywords(beautify);
            }
            wasBuildOptActive = beautify.active;
        }
Ejemplo n.º 3
0
        IEnumerator DoBlink(float duration, float maxValue)
        {
            Beautify          beautify = settings;
            float             start    = Time.time;
            WaitForEndOfFrame w        = new WaitForEndOfFrame();

            beautify.vignettingBlink.overrideState = true;
            float t;

            // Close
            do
            {
                t = (Time.time - start) / duration;
                if (t > 1f)
                {
                    t = 1f;
                }
                float easeOut = t * (2f - t);
                beautify.vignettingBlink.value = easeOut * maxValue;
                yield return(w);
            } while (t < 1f);

            // Open
            start = Time.time;
            do
            {
                t = (Time.time - start) / duration;
                if (t > 1f)
                {
                    t = 1f;
                }
                float easeIn = t * t;
                beautify.vignettingBlink.value = (1f - easeIn) * maxValue;
                yield return(w);
            } while (t < 1f);
            beautify.vignettingBlink.overrideState = false;
        }
Ejemplo n.º 4
0
        public static void SetStripShaderKeywords(Beautify beautify)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            bool auto = beautify.optimizeBuildBeautifyAuto.value;

            if (auto)
            {
                beautify.stripBeautifyBloom.value = false;
                beautify.stripBeautifyDoF.value   = false;
                beautify.stripBeautifyDoFTransparentSupport.value = false;
                beautify.stripBeautifyLensDirt.value      = false;
                beautify.stripBeautifyLUT.value           = false;
                beautify.stripBeautifyOutline.value       = false;
                beautify.stripBeautifyNightVision.value   = false;
                beautify.stripBeautifyColorTweaks.value   = false;
                beautify.stripBeautifyPurkinje.value      = false;
                beautify.stripBeautifyTonemapping.value   = false;
                beautify.stripBeautifyDithering.value     = false;
                beautify.stripBeautifySharpen.value       = false;
                beautify.stripBeautifyEyeAdaptation.value = false;
                beautify.stripBeautifyVignetting.value    = false;
            }
            if (beautify.stripBeautifyBloom.value || (auto && beautify.bloomIntensity.value <= 0))
            {
                sb.Append(BeautifyRendererFeature.SKW_BLOOM);
                sb.Append(BeautifyRendererFeature.SKW_BLOOM_USE_DEPTH);
            }
            if (beautify.stripBeautifyDoF.value || (auto && !beautify.depthOfField.value))
            {
                sb.Append(BeautifyRendererFeature.SKW_DEPTH_OF_FIELD);
            }
            if (beautify.stripBeautifyDoF.value || (auto && !beautify.depthOfFieldTransparentSupport.value))
            {
                sb.Append(BeautifyRendererFeature.SKW_DEPTH_OF_FIELD_TRANSPARENT);
            }
            if (beautify.stripBeautifyLensDirt.value || (auto && beautify.lensDirtIntensity.value <= 0))
            {
                sb.Append(BeautifyRendererFeature.SKW_DIRT);
            }
            bool usesLUT = beautify.lut.value && beautify.lutTexture.value != null;

            if (beautify.stripBeautifyLUT.value || (auto && !usesLUT))
            {
                sb.Append(BeautifyRendererFeature.SKW_LUT);
            }
            if (beautify.stripBeautifyOutline.value || (auto && !beautify.outline.value))
            {
                sb.Append(BeautifyRendererFeature.SKW_OUTLINE);
            }
            if (beautify.stripBeautifyNightVision.value || (auto && !beautify.nightVision.value))
            {
                sb.Append(BeautifyRendererFeature.SKW_NIGHT_VISION);
            }
            bool usesColorTweaks = beautify.sepia.value > 0 || beautify.daltonize.value > 0 || beautify.colorTempBlend.value > 0;

            if (beautify.stripBeautifyColorTweaks.value || (auto && !usesColorTweaks))
            {
                sb.Append(BeautifyRendererFeature.SKW_COLOR_TWEAKS);
            }
            if (beautify.stripBeautifyPurkinje.value || (auto && !beautify.purkinje.value))
            {
                sb.Append(BeautifyRendererFeature.SKW_PURKINJE);
            }
            if (beautify.stripBeautifyTonemapping.value || (auto && beautify.tonemap.value != Beautify.TonemapOperator.ACES))
            {
                sb.Append(BeautifyRendererFeature.SKW_TONEMAP_ACES);
            }
            if (beautify.stripBeautifyDithering.value || (auto && beautify.ditherIntensity.value <= 0))
            {
                sb.Append(BeautifyRendererFeature.SKW_DITHER);
            }
            if (beautify.stripBeautifySharpen.value || (auto && beautify.sharpenIntensity.value <= 0))
            {
                sb.Append(BeautifyRendererFeature.SKW_SHARPEN);
            }
            if (beautify.stripBeautifyEyeAdaptation.value || (auto && !beautify.eyeAdaptation.value))
            {
                sb.Append(BeautifyRendererFeature.SKW_EYE_ADAPTATION);
            }
            if (beautify.stripBeautifyChromaticAberration.value || (auto && beautify.chromaticAberrationIntensity.value <= 0))
            {
                sb.Append(BeautifyRendererFeature.SKW_CHROMATIC_ABERRATION);
            }

            float outerRing         = 1f - beautify.vignettingOuterRing.value;
            float innerRing         = 1f - beautify.vignettingInnerRing.value;
            bool  vignettingEnabled = outerRing < 1 || innerRing < 1f || beautify.vignettingFade.value > 0 || beautify.vignettingBlink.value > 0;

            if (beautify.stripBeautifyVignetting.value || (auto && !vignettingEnabled))
            {
                sb.Append(BeautifyRendererFeature.SKW_VIGNETTING);
                sb.Append(BeautifyRendererFeature.SKW_VIGNETTING_MASK);
            }

            bool stripUnityPPS = beautify.optimizeBuildUnityPPSAuto.value;

            if (beautify.stripUnityBloom.value || stripUnityPPS)
            {
                sb.Append("_BLOOM_LQ _BLOOM_HQ _BLOOM_LQ_DIRT _BLOOM_HQ_DIRT");
            }
            if (beautify.stripUnityChromaticAberration.value || stripUnityPPS)
            {
                sb.Append("_CHROMATIC_ABERRATION");
            }
            if (beautify.stripUnityDistortion.value || stripUnityPPS)
            {
                sb.Append("_DISTORTION");
            }
            if (beautify.stripUnityFilmGrain.value || stripUnityPPS)
            {
                sb.Append("_FILM_GRAIN");
            }
            if (beautify.stripUnityTonemapping.value || stripUnityPPS)
            {
                sb.Append("_TONEMAP_ACES");
            }
            PlayerPrefs.SetString(PLAYER_PREF_KEYNAME, sb.ToString());
        }
Ejemplo n.º 5
0
 void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
 {
     _instance       = null;
     _beautifyVolume = null;
     _beautify       = null;
 }