@@ -10,6 +10,8 @@ namespace Coffee.UIEffects
10
10
{
11
11
public class UIEffectProjectSettings : PreloadedProjectSettings < UIEffectProjectSettings >
12
12
{
13
+ private static readonly int s_PreferSamplingSize = Shader . PropertyToID ( "_UIEffect_PreferSamplingSize" ) ;
14
+
13
15
[ Tooltip (
14
16
"The sensitivity of the transformation when `Use Target Transform` is enabled in the `UIEffectReplica` component." ) ]
15
17
[ Header ( "Setting" ) ]
@@ -19,6 +21,9 @@ public class UIEffectProjectSettings : PreloadedProjectSettings<UIEffectProjectS
19
21
[ SerializeField ]
20
22
internal List < UIEffect > m_RuntimePresets = new List < UIEffect > ( ) ;
21
23
24
+ [ SerializeField ]
25
+ private PreferSamplingSize m_PreferSamplingSize = PreferSamplingSize . None ;
26
+
22
27
[ HideInInspector ]
23
28
[ SerializeField ]
24
29
internal ShaderVariantCollection m_ShaderVariantCollection ;
@@ -27,6 +32,17 @@ public class UIEffectProjectSettings : PreloadedProjectSettings<UIEffectProjectS
27
32
[ SerializeField ]
28
33
private ShaderVariantRegistry m_ShaderVariantRegistry = new ShaderVariantRegistry ( ) ;
29
34
35
+ public static PreferSamplingSize preferSamplingSize
36
+ {
37
+ get => instance . m_PreferSamplingSize ;
38
+ set
39
+ {
40
+ if ( instance . m_PreferSamplingSize == value ) return ;
41
+ instance . m_PreferSamplingSize = value ;
42
+ instance . SetPreferSamplingSize ( ) ;
43
+ }
44
+ }
45
+
30
46
public static ShaderVariantRegistry shaderRegistry => instance . m_ShaderVariantRegistry ;
31
47
32
48
public static ShaderVariantCollection shaderVariantCollection => shaderRegistry . shaderVariantCollection ;
@@ -62,6 +78,20 @@ public static UIEffect LoadRuntimePreset(string presetName)
62
78
return null ;
63
79
}
64
80
81
+ protected override void OnEnable ( )
82
+ {
83
+ base . OnEnable ( ) ;
84
+ SetPreferSamplingSize ( ) ;
85
+ }
86
+
87
+ private void SetPreferSamplingSize ( )
88
+ {
89
+ if ( instance == this )
90
+ {
91
+ Shader . SetGlobalInt ( s_PreferSamplingSize , ( int ) instance . m_PreferSamplingSize ) ;
92
+ }
93
+ }
94
+
65
95
#if UNITY_EDITOR
66
96
private const string k_PresetDir = "UIEffectPresets" ;
67
97
private const string k_PresetSaveDir = "Assets/ProjectSettings/" + k_PresetDir ;
@@ -82,6 +112,11 @@ private void Reset()
82
112
m_ShaderVariantRegistry . InitializeIfNeeded ( this , "(UIEffect)" ) ;
83
113
}
84
114
115
+ private void OnValidate ( )
116
+ {
117
+ SetPreferSamplingSize ( ) ;
118
+ }
119
+
85
120
internal static UIEffect [ ] LoadEditorPresets ( )
86
121
{
87
122
var dirs = AssetDatabase . FindAssets ( k_PresetDir + " t:folder" )
0 commit comments