experiments with fresnel and shadergraph
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.6 / PostProcessing / Editor / Utils / GlobalSettings.cs
blob7cde6b286b4004477ef8d6bc24f1e8115397a698
1 using UnityEngine;
2 using UnityEngine.Rendering.PostProcessing;
4 namespace UnityEditor.Rendering.PostProcessing
6 static class GlobalSettings
8 static class Keys
10 internal const string trackballSensitivity = "PostProcessing.Trackball.Sensitivity";
11 internal const string volumeGizmoColor = "PostProcessing.Volume.GizmoColor";
12 internal const string currentChannelMixer = "PostProcessing.ChannelMixer.CurrentChannel";
13 internal const string currentCurve = "PostProcessing.Curve.Current";
16 static bool m_Loaded = false;
18 static float m_TrackballSensitivity = 0.2f;
19 internal static float trackballSensitivity
21 get { return m_TrackballSensitivity; }
22 set { TrySave(ref m_TrackballSensitivity, value, Keys.trackballSensitivity); }
25 static Color m_VolumeGizmoColor = new Color(0.2f, 0.8f, 0.1f, 0.5f);
26 internal static Color volumeGizmoColor
28 get { return m_VolumeGizmoColor; }
29 set { TrySave(ref m_VolumeGizmoColor, value, Keys.volumeGizmoColor); }
32 static int m_CurrentChannelMixer = 0;
33 internal static int currentChannelMixer
35 get { return m_CurrentChannelMixer; }
36 set { TrySave(ref m_CurrentChannelMixer, value, Keys.currentChannelMixer); }
39 static int m_CurrentCurve = 0;
40 internal static int currentCurve
42 get { return m_CurrentCurve; }
43 set { TrySave(ref m_CurrentCurve, value, Keys.currentCurve); }
46 static GlobalSettings()
48 Load();
51 #if UNITY_2018_3_OR_NEWER
52 [SettingsProvider]
53 static SettingsProvider PreferenceGUI()
55 return new SettingsProvider("Preferences/Post-processing", SettingsScope.User)
57 guiHandler = searchContext => OpenGUI()
60 #else
61 [PreferenceItem("Post-processing")]
62 static void PreferenceGUI()
64 OpenGUI();
66 #endif
68 static void OpenGUI()
70 if (!m_Loaded)
71 Load();
73 EditorGUILayout.Space();
75 trackballSensitivity = EditorGUILayout.Slider("Trackballs Sensitivity", trackballSensitivity, 0.05f, 1f);
76 volumeGizmoColor = EditorGUILayout.ColorField("Volume Gizmo Color", volumeGizmoColor);
79 static void Load()
81 m_TrackballSensitivity = EditorPrefs.GetFloat(Keys.trackballSensitivity, 0.2f);
82 m_VolumeGizmoColor = GetColor(Keys.volumeGizmoColor, new Color(0.2f, 0.8f, 0.1f, 0.5f));
83 m_CurrentChannelMixer = EditorPrefs.GetInt(Keys.currentChannelMixer, 0);
84 m_CurrentCurve = EditorPrefs.GetInt(Keys.currentCurve, 0);
86 m_Loaded = true;
89 static Color GetColor(string key, Color defaultValue)
91 int value = EditorPrefs.GetInt(key, (int)ColorUtilities.ToHex(defaultValue));
92 return ColorUtilities.ToRGBA((uint)value);
95 static void TrySave<T>(ref T field, T newValue, string key)
97 if (field.Equals(newValue))
98 return;
100 if (typeof(T) == typeof(float))
101 EditorPrefs.SetFloat(key, (float)(object)newValue);
102 else if (typeof(T) == typeof(int))
103 EditorPrefs.SetInt(key, (int)(object)newValue);
104 else if (typeof(T) == typeof(bool))
105 EditorPrefs.SetBool(key, (bool)(object)newValue);
106 else if (typeof(T) == typeof(string))
107 EditorPrefs.SetString(key, (string)(object)newValue);
108 else if (typeof(T) == typeof(Color))
109 EditorPrefs.SetInt(key, (int)ColorUtilities.ToHex((Color)(object)newValue));
111 field = newValue;