Skip to content

Commit 6323f8f

Browse files
committed
Update variable naming convention
1 parent 2650091 commit 6323f8f

File tree

4 files changed

+113
-97
lines changed

4 files changed

+113
-97
lines changed

Runtime/CinematicBars.cs

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ namespace Zigurous.UI
1313
[AddComponentMenu("Zigurous/UI/Misc/Cinematic Bars")]
1414
public sealed class CinematicBars : MonoBehaviour
1515
{
16+
[SerializeField]
17+
[Tooltip("The color of the mattes.")]
18+
private Color m_Color = Color.black;
19+
20+
[SerializeField]
21+
[Tooltip("The material of the mattes.")]
22+
private Material m_Material = null;
23+
24+
[SerializeField]
25+
[Tooltip("The aspect ratio of the mattes.")]
26+
private float m_AspectRatio = 2.35f;
27+
28+
[SerializeField]
29+
[Tooltip("The amount of seconds it takes to animate the mattes.")]
30+
private float m_AnimationDuration = 0.5f;
31+
1632
/// <summary>
1733
/// The top letterbox matte (Read only).
1834
/// </summary>
@@ -28,61 +44,49 @@ public sealed class CinematicBars : MonoBehaviour
2844
/// </summary>
2945
public float matteHeight { get; private set; }
3046

31-
[SerializeField]
32-
[Tooltip("The color of the mattes.")]
33-
private Color _color = Color.black;
34-
3547
/// <summary>
3648
/// The color of the mattes.
3749
/// </summary>
3850
public Color color
3951
{
40-
get { return _color; }
41-
set { _color = value; UpdateStyles(); }
52+
get => m_Color;
53+
set { m_Color = value; UpdateStyles(); }
4254
}
4355

44-
[SerializeField]
45-
[Tooltip("The material of the mattes.")]
46-
private Material _material = null;
47-
4856
/// <summary>
4957
/// The material of the mattes.
5058
/// </summary>
5159
public Material material
5260
{
53-
get { return _material; }
54-
set { _material = value; UpdateStyles(); }
61+
get => m_Material;
62+
set { m_Material = value; UpdateStyles(); }
5563
}
5664

57-
[SerializeField]
58-
[Tooltip("The aspect ratio of the mattes.")]
59-
private float _aspectRatio = 2.35f;
60-
6165
/// <summary>
6266
/// The aspect ratio of the mattes.
6367
/// </summary>
6468
public float aspectRatio
6569
{
66-
get { return _aspectRatio; }
67-
set { _aspectRatio = value; UpdateMattes(); }
70+
get => m_AspectRatio;
71+
set { m_AspectRatio = value; UpdateMattes(); }
6872
}
6973

7074
/// <summary>
7175
/// The amount of seconds it takes to animate the mattes.
7276
/// </summary>
73-
[Tooltip("The amount of seconds it takes to animate the mattes.")]
74-
public float animationDuration = 0.5f;
77+
public float animationDuration
78+
{
79+
get => m_AnimationDuration;
80+
set => m_AnimationDuration = value;
81+
}
7582

7683
/// <summary>
7784
/// The coroutine that animates the mattes.
7885
/// </summary>
79-
private Coroutine _animation;
86+
private Coroutine coroutine;
8087

8188
#if UNITY_EDITOR
82-
/// <summary>
83-
/// Whether the current settings have been invalidated.
84-
/// </summary>
85-
private bool _invalidated;
89+
private bool invalidated;
8690
#endif
8791

8892
private void Awake()
@@ -132,10 +136,12 @@ private void OnDestroy()
132136
}
133137
}
134138

139+
#if UNITY_EDITOR
135140
private void OnValidate()
136141
{
137-
_invalidated = true;
142+
invalidated = true;
138143
}
144+
#endif
139145

140146
private void OnEnable()
141147
{
@@ -152,16 +158,18 @@ private void OnScreenResize(int width, int height)
152158
UpdateMattes(animated: false);
153159
}
154160

161+
#if UNITY_EDITOR
155162
private void Update()
156163
{
157-
if (_invalidated)
164+
if (invalidated)
158165
{
159166
UpdateStyles();
160167
UpdateMattes(animated: false);
161168

162-
_invalidated = false;
169+
invalidated = false;
163170
}
164171
}
172+
#endif
165173

166174
private void UpdateMattes()
167175
{
@@ -180,11 +188,11 @@ private void UpdateMattes(bool animated)
180188

181189
if (animated)
182190
{
183-
if (_animation != null) {
184-
StopCoroutine(_animation);
191+
if (coroutine != null) {
192+
StopCoroutine(coroutine);
185193
}
186194

187-
_animation = StartCoroutine(Animate(matteHeight, desiredHeight));
195+
coroutine = StartCoroutine(Animate(matteHeight, desiredHeight));
188196
}
189197
else
190198
{

Runtime/InverseMask.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace Zigurous.UI
1212
[AddComponentMenu("Zigurous/UI/Effects/Inverse Mask")]
1313
public sealed class InverseMask : MonoBehaviour
1414
{
15-
private static Material _cutoutMaterial;
16-
private static Material _contentMaterial;
15+
private static Material m_CutoutMaterial;
16+
private static Material m_ContentMaterial;
1717

1818
/// <summary>
1919
/// The shared material applied to an image that is masking another
@@ -23,22 +23,22 @@ public static Material cutoutMaterial
2323
{
2424
get
2525
{
26-
if (_cutoutMaterial == null)
26+
if (m_CutoutMaterial == null)
2727
{
28-
_cutoutMaterial = new Material(Shader.Find("UI/Default"));
29-
_cutoutMaterial.name = "UIInverseMask-Cutout";
30-
_cutoutMaterial.color = new Color(1f, 1f, 1f, 1f / 256f);
31-
_cutoutMaterial.shaderKeywords = new string[] { "UNITY_UI_ALPHACLIP" };
32-
_cutoutMaterial.SetInt("_Stencil", 1);
33-
_cutoutMaterial.SetInt("_StencilComp", 8);
34-
_cutoutMaterial.SetInt("_StencilOp", 2);
35-
_cutoutMaterial.SetInt("_StencilWriteMask", 255);
36-
_cutoutMaterial.SetInt("_StencilReadMask", 255);
37-
_cutoutMaterial.SetInt("_ColorMask", 0);
38-
_cutoutMaterial.SetInt("_UseUIAlphaClip", 1);
28+
m_CutoutMaterial = new Material(Shader.Find("UI/Default"));
29+
m_CutoutMaterial.name = "UIInverseMask-Cutout";
30+
m_CutoutMaterial.color = new Color(1f, 1f, 1f, 1f / 256f);
31+
m_CutoutMaterial.shaderKeywords = new string[] { "UNITY_UI_ALPHACLIP" };
32+
m_CutoutMaterial.SetInt("_Stencil", 1);
33+
m_CutoutMaterial.SetInt("_StencilComp", 8);
34+
m_CutoutMaterial.SetInt("_StencilOp", 2);
35+
m_CutoutMaterial.SetInt("_StencilWriteMask", 255);
36+
m_CutoutMaterial.SetInt("_StencilReadMask", 255);
37+
m_CutoutMaterial.SetInt("_ColorMask", 0);
38+
m_CutoutMaterial.SetInt("_UseUIAlphaClip", 1);
3939
}
4040

41-
return _cutoutMaterial;
41+
return m_CutoutMaterial;
4242
}
4343
}
4444

@@ -51,38 +51,38 @@ public static Material contentMaterial
5151
{
5252
get
5353
{
54-
if (_contentMaterial == null)
54+
if (m_ContentMaterial == null)
5555
{
56-
_contentMaterial = new Material(Shader.Find("UI/Default"));
57-
_contentMaterial.name = "UIInverseMask-Content";
58-
_contentMaterial.color = Color.white;
59-
_contentMaterial.SetInt("_Stencil", 2);
60-
_contentMaterial.SetInt("_StencilComp", 3);
61-
_contentMaterial.SetInt("_StencilOp", 0);
62-
_contentMaterial.SetInt("_StencilWriteMask", 0);
63-
_contentMaterial.SetInt("_StencilReadMask", 1);
64-
_contentMaterial.SetInt("_ColorMask", 15);
65-
_contentMaterial.SetInt("_UseUIAlphaClip", 0);
56+
m_ContentMaterial = new Material(Shader.Find("UI/Default"));
57+
m_ContentMaterial.name = "UIInverseMask-Content";
58+
m_ContentMaterial.color = Color.white;
59+
m_ContentMaterial.SetInt("_Stencil", 2);
60+
m_ContentMaterial.SetInt("_StencilComp", 3);
61+
m_ContentMaterial.SetInt("_StencilOp", 0);
62+
m_ContentMaterial.SetInt("_StencilWriteMask", 0);
63+
m_ContentMaterial.SetInt("_StencilReadMask", 1);
64+
m_ContentMaterial.SetInt("_ColorMask", 15);
65+
m_ContentMaterial.SetInt("_UseUIAlphaClip", 0);
6666
}
6767

68-
return _contentMaterial;
68+
return m_ContentMaterial;
6969
}
7070
}
7171

7272
#if UNITY_EDITOR
73-
private bool _invalidated;
73+
private bool invalidated;
7474

7575
private void OnValidate()
7676
{
77-
_invalidated = true;
77+
invalidated = true;
7878
}
7979

8080
private void Update()
8181
{
82-
if (_invalidated)
82+
if (invalidated)
8383
{
8484
Apply();
85-
_invalidated = false;
85+
invalidated = false;
8686
}
8787
}
8888
#endif

Runtime/Letterboxing.cs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ namespace Zigurous.UI
1111
[AddComponentMenu("Zigurous/UI/Misc/Letterboxing")]
1212
public sealed class Letterboxing : MonoBehaviour
1313
{
14+
[SerializeField]
15+
[Tooltip("The aspect ratio of the mattes.")]
16+
private float m_AspectRatio = 2.35f;
17+
18+
[SerializeField]
19+
[Tooltip("The amount of seconds it takes to animate the mattes.")]
20+
private float m_AnimationDuration = 0.5f;
21+
1422
/// <summary>
1523
/// The camera being letterboxed (Read only).
1624
/// </summary>
@@ -21,35 +29,31 @@ public sealed class Letterboxing : MonoBehaviour
2129
/// </summary>
2230
public float viewportHeight => camera.rect.height;
2331

24-
[SerializeField]
25-
[Tooltip("The aspect ratio of the mattes.")]
26-
private float _aspectRatio = 2.35f;
27-
2832
/// <summary>
2933
/// The aspect ratio of the mattes.
3034
/// </summary>
3135
public float aspectRatio
3236
{
33-
get { return _aspectRatio; }
34-
set { _aspectRatio = value; UpdateViewport(); }
37+
get => m_AspectRatio;
38+
set { m_AspectRatio = value; UpdateViewport(); }
3539
}
3640

3741
/// <summary>
3842
/// The amount of seconds it takes to animate the mattes.
3943
/// </summary>
40-
[Tooltip("The amount of seconds it takes to animate the mattes.")]
41-
public float animationDuration = 0.5f;
44+
public float animationDuration
45+
{
46+
get => m_AnimationDuration;
47+
set => m_AnimationDuration = value;
48+
}
4249

4350
/// <summary>
4451
/// The coroutine that animates the mattes.
4552
/// </summary>
46-
private Coroutine _animation;
53+
private Coroutine coroutine;
4754

4855
#if UNITY_EDITOR
49-
/// <summary>
50-
/// Whether the current settings have been invalidated.
51-
/// </summary>
52-
private bool _invalidated;
56+
private bool invalidated;
5357
#endif
5458

5559
private void Awake()
@@ -69,10 +73,12 @@ private void OnDestroy()
6973
}
7074
}
7175

76+
#if UNITY_EDITOR
7277
private void OnValidate()
7378
{
74-
_invalidated = true;
79+
invalidated = true;
7580
}
81+
#endif
7682

7783
private void OnEnable()
7884
{
@@ -89,15 +95,17 @@ private void OnScreenResize(int width, int height)
8995
UpdateViewport(animated: false);
9096
}
9197

98+
#if UNITY_EDITOR
9299
private void Update()
93100
{
94-
if (_invalidated)
101+
if (invalidated)
95102
{
96103
UpdateViewport(animated: false);
97104

98-
_invalidated = false;
105+
invalidated = false;
99106
}
100107
}
108+
#endif
101109

102110
private void UpdateViewport()
103111
{
@@ -116,11 +124,11 @@ private void UpdateViewport(bool animated)
116124

117125
if (animated)
118126
{
119-
if (_animation != null) {
120-
StopCoroutine(_animation);
127+
if (coroutine != null) {
128+
StopCoroutine(coroutine);
121129
}
122130

123-
_animation = StartCoroutine(Animate(viewportHeight, desiredHeight));
131+
coroutine = StartCoroutine(Animate(viewportHeight, desiredHeight));
124132
}
125133
else
126134
{

0 commit comments

Comments
 (0)