- Home /
Question by
Forsix · Oct 07, 2020 at 10:01 PM ·
playerprefssavingsettingspost processing
Saving Post Processing as a graphic option
Okay, so i made an settings scene which have 2 graphic options (performance and good). Performance option is just disabling the post procession, but i don't know how to set PlayerPrefs to save this options to next scenes (menu etc.) Here's code:
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;
public class OptionsScene : MonoBehaviour
{
public PostProcessVolume ppv;
Bloom bloom = null;
ColorGrading cg = null;
Vignette vg = null;
void Start()
{
ppv.profile.TryGetSettings(out bloom);
ppv.profile.TryGetSettings(out cg);
ppv.profile.TryGetSettings(out vg);
}
public void OnGoodClick()
{
bloom.intensity.value = 15f;
cg.postExposure.value = 1f;
cg.saturation.value = 22f;
vg.intensity.value = 1f;
}
public void OnPerformanceClick()
{
bloom.intensity.value = 0f;
cg.postExposure.value = 0f;
cg.saturation.value = 0f;
vg.intensity.value = 0f;
}
}
Comment
Answer by Aviryx · Oct 07, 2020 at 11:42 PM
https://learn.unity.com/tutorial/persistence-saving-and-loading-data
This covers both saving data via player prefs, and persisting data between sessions using binary files. It's an old video but still works on current versions of unity (I use the binary file type in Unity 2020).