Skip to content

Commit ccbb2bf

Browse files
committed
Change serialized property naming convention
1 parent bb94027 commit ccbb2bf

17 files changed

+139
-129
lines changed

Editor/AnimatorParameterPropertyDrawer.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,20 @@ namespace Zigurous.Animation.Editor
66
[CustomPropertyDrawer(typeof(AnimatorParameter))]
77
public sealed class AnimatorParameterPropertyDrawer : PropertyDrawer
88
{
9-
private SerializedProperty _name;
10-
private SerializedProperty _hash;
11-
129
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1310
{
14-
if (_name == null) {
15-
_name = property.FindPropertyRelative("_name");
16-
}
17-
18-
if (_hash == null) {
19-
_hash = property.FindPropertyRelative("_hash");
20-
}
11+
SerializedProperty name = property.FindPropertyRelative("m_Name");
12+
SerializedProperty hash = property.FindPropertyRelative("m_Hash");
2113

2214
EditorGUI.BeginProperty(position, label, property);
2315
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
2416

25-
string name = EditorGUI.TextField(position, _name.stringValue);
17+
string nameValue = EditorGUI.TextField(position, name.stringValue);
2618

27-
if (name != _name.stringValue)
19+
if (nameValue != name.stringValue)
2820
{
29-
_name.stringValue = name;
30-
_hash.intValue = Animator.StringToHash(name);
21+
name.stringValue = nameValue;
22+
hash.intValue = Animator.StringToHash(nameValue);
3123
}
3224

3325
EditorGUI.EndProperty();

Editor/Timing01PropertyDrawer.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ public sealed class Timing01PropertyDrawer : PropertyDrawer
88
{
99
private const float horizontalSpacing = 4f;
1010

11-
private SerializedProperty _start;
12-
private SerializedProperty _end;
13-
1411
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1512
{
1613
// Start drawing the property
@@ -27,16 +24,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2724
EditorGUI.indentLevel = 0;
2825

2926
// Create references to child fields
30-
if (_start == null) _start = property.FindPropertyRelative("_start");
31-
if (_end == null) _end = property.FindPropertyRelative("_end");
27+
SerializedProperty start = property.FindPropertyRelative("m_Start");
28+
SerializedProperty end = property.FindPropertyRelative("m_End");
3229

3330
// Calculate the bounds of the child fields
3431
Rect rect = new Rect(position);
3532
rect.width = (position.width - horizontalSpacing) / 2f;
3633

3734
// Draw the child fields
38-
rect = SliderWithChangeCheck(_start, rect, "Start");
39-
rect = SliderWithChangeCheck(_end, rect, "End");
35+
rect = SliderWithChangeCheck(start, rect, "Start");
36+
rect = SliderWithChangeCheck(end, rect, "End");
4037

4138
// Set sizes back to their original values
4239
EditorGUI.indentLevel = originalIndent;

Editor/TimingPropertyDrawer.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ public sealed class TimingPropertyDrawer : PropertyDrawer
88
{
99
private const float horizontalSpacing = 4f;
1010

11-
private SerializedProperty _start;
12-
private SerializedProperty _end;
13-
1411
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1512
{
1613
// Start drawing the property
@@ -27,16 +24,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2724
EditorGUI.indentLevel = 0;
2825

2926
// Create references to child fields
30-
if (_start == null) _start = property.FindPropertyRelative("start");
31-
if (_end == null) _end = property.FindPropertyRelative("end");
27+
SerializedProperty start = property.FindPropertyRelative("m_Start");
28+
SerializedProperty end = property.FindPropertyRelative("m_End");
3229

3330
// Calculate the bounds of the child fields
3431
Rect rect = new Rect(position);
3532
rect.width = (position.width - horizontalSpacing) / 2f;
3633

3734
// Draw the child fields
38-
rect = FloatFieldWithChangeCheck(_start, rect);
39-
rect = FloatFieldWithChangeCheck(_end, rect);
35+
rect = FloatFieldWithChangeCheck(start, rect);
36+
rect = FloatFieldWithChangeCheck(end, rect);
4037

4138
// Set sizes back to their original values
4239
EditorGUI.indentLevel = originalIndent;

Editor/TimingRange01PropertyDrawer.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ public sealed class TimingRange01PropertyDrawer : PropertyDrawer
88
{
99
private const float horizontalSpacing = 4f;
1010

11-
private SerializedProperty _min;
12-
private SerializedProperty _max;
13-
1411
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1512
{
1613
// Start drawing the property
@@ -27,16 +24,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2724
EditorGUI.indentLevel = 0;
2825

2926
// Create references to child fields
30-
if (_min == null) _min = property.FindPropertyRelative("_min");
31-
if (_max == null) _max = property.FindPropertyRelative("_max");
27+
SerializedProperty min = property.FindPropertyRelative("m_Min");
28+
SerializedProperty max = property.FindPropertyRelative("m_Max");
3229

3330
// Calculate the bounds of the child fields
3431
Rect rect = new Rect(position);
3532
rect.width = (position.width - horizontalSpacing) / 2f;
3633

3734
// Draw the child fields
38-
rect = SliderWithChangeCheck(_min, rect, "Min");
39-
rect = SliderWithChangeCheck(_max, rect, "Max");
35+
rect = SliderWithChangeCheck(min, rect, "Min");
36+
rect = SliderWithChangeCheck(max, rect, "Max");
4037

4138
// Set sizes back to their original values
4239
EditorGUI.indentLevel = originalIndent;

Editor/TimingRangePropertyDrawer.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ public sealed class TimingRangePropertyDrawer : PropertyDrawer
88
{
99
private const float horizontalSpacing = 4f;
1010

11-
private SerializedProperty _min;
12-
private SerializedProperty _max;
13-
1411
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1512
{
1613
// Start drawing the property
@@ -27,16 +24,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2724
EditorGUI.indentLevel = 0;
2825

2926
// Create references to child fields
30-
if (_min == null) _min = property.FindPropertyRelative("min");
31-
if (_max == null) _max = property.FindPropertyRelative("max");
27+
SerializedProperty min = property.FindPropertyRelative("m_Min");
28+
SerializedProperty max = property.FindPropertyRelative("m_Max");
3229

3330
// Calculate the bounds of the child fields
3431
Rect rect = new Rect(position);
3532
rect.width = (position.width - horizontalSpacing) / 2f;
3633

3734
// Draw the child fields
38-
rect = FloatFieldWithChangeCheck(_min, rect);
39-
rect = FloatFieldWithChangeCheck(_max, rect);
35+
rect = FloatFieldWithChangeCheck(min, rect);
36+
rect = FloatFieldWithChangeCheck(max, rect);
4037

4138
// Set sizes back to their original values
4239
EditorGUI.indentLevel = originalIndent;

Runtime/DataStructures/AnimatorParameter.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct AnimatorParameter
1414
{
1515
[SerializeField]
1616
[HideInInspector]
17-
private int _hash;
17+
private int m_Hash;
1818

1919
/// <summary>
2020
/// The hash id of the animator parameter (Read only).
@@ -23,27 +23,27 @@ public int hash
2323
{
2424
get
2525
{
26-
if (_hash == 0) {
27-
_hash = Animator.StringToHash(_name);
26+
if (m_Hash == 0) {
27+
m_Hash = Animator.StringToHash(m_Name);
2828
}
29-
return _hash;
29+
return m_Hash;
3030
}
3131
}
3232

3333
[SerializeField]
3434
[Tooltip("The name of the animator parameter.")]
35-
private string _name;
35+
private string m_Name;
3636

3737
/// <summary>
3838
/// The name of the animator parameter.
3939
/// </summary>
4040
public string name
4141
{
42-
get => _name;
42+
get => m_Name;
4343
set
4444
{
45-
_name = value;
46-
_hash = Animator.StringToHash(value);
45+
m_Name = value;
46+
m_Hash = Animator.StringToHash(value);
4747
}
4848
}
4949

@@ -53,8 +53,8 @@ public string name
5353
/// <param name="name">The name of the animator parameter.</param>
5454
public AnimatorParameter(string name)
5555
{
56-
_name = name;
57-
_hash = Animator.StringToHash(name);
56+
m_Name = name;
57+
m_Hash = Animator.StringToHash(name);
5858
}
5959

6060
/// <summary>

Runtime/DataStructures/SmoothDamp.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ namespace Zigurous.Animation
1010
[System.Serializable]
1111
public abstract class SmoothDamp<T>
1212
{
13-
protected T _value;
14-
protected T _velocity;
13+
protected T m_Value;
14+
protected T m_Velocity;
1515

1616
/// <summary>
1717
/// The current value (Read only).
1818
/// </summary>
1919
public T value
2020
{
21-
get { return _value; }
22-
protected set { _value = value; }
21+
get { return m_Value; }
22+
protected set { m_Value = value; }
2323
}
2424

2525
/// <summary>
@@ -28,8 +28,8 @@ public T value
2828
/// </summary>
2929
public T velocity
3030
{
31-
get { return _velocity; }
32-
protected set { _velocity = value; }
31+
get { return m_Velocity; }
32+
protected set { m_Velocity = value; }
3333
}
3434

3535
/// <summary>

Runtime/DataStructures/SmoothDampFloat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class SmoothDampFloat : SmoothDamp<float>
1616
/// <returns>The new current value.</returns>
1717
public override float Update(float target)
1818
{
19-
value = Mathf.SmoothDamp(value, target, ref _velocity, smoothTime, maxSpeed);
19+
value = Mathf.SmoothDamp(value, target, ref m_Velocity, smoothTime, maxSpeed);
2020
return value;
2121
}
2222

@@ -29,7 +29,7 @@ public override float Update(float target)
2929
/// <returns>The new current value.</returns>
3030
public override float Update(float target, float deltaTime)
3131
{
32-
value = Mathf.SmoothDamp(value, target, ref _velocity, smoothTime, maxSpeed, deltaTime);
32+
value = Mathf.SmoothDamp(value, target, ref m_Velocity, smoothTime, maxSpeed, deltaTime);
3333
return value;
3434
}
3535

Runtime/DataStructures/SmoothDampVector2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class SmoothDampVector2 : SmoothDamp<Vector2>
1616
/// <returns>The new current value.</returns>
1717
public override Vector2 Update(Vector2 target)
1818
{
19-
value = Vector2.SmoothDamp(value, target, ref _velocity, smoothTime, maxSpeed);
19+
value = Vector2.SmoothDamp(value, target, ref m_Velocity, smoothTime, maxSpeed);
2020
return value;
2121
}
2222

@@ -29,7 +29,7 @@ public override Vector2 Update(Vector2 target)
2929
/// <returns>The new current value.</returns>
3030
public override Vector2 Update(Vector2 target, float deltaTime)
3131
{
32-
value = Vector2.SmoothDamp(value, target, ref _velocity, smoothTime, maxSpeed, deltaTime);
32+
value = Vector2.SmoothDamp(value, target, ref m_Velocity, smoothTime, maxSpeed, deltaTime);
3333
return value;
3434
}
3535

Runtime/DataStructures/SmoothDampVector3.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class SmoothDampVector3 : SmoothDamp<Vector3>
1616
/// <returns>The new current value.</returns>
1717
public override Vector3 Update(Vector3 target)
1818
{
19-
value = Vector3.SmoothDamp(value, target, ref _velocity, smoothTime, maxSpeed);
19+
value = Vector3.SmoothDamp(value, target, ref m_Velocity, smoothTime, maxSpeed);
2020
return value;
2121
}
2222

@@ -29,7 +29,7 @@ public override Vector3 Update(Vector3 target)
2929
/// <returns>The new current value.</returns>
3030
public override Vector3 Update(Vector3 target, float deltaTime)
3131
{
32-
value = Vector3.SmoothDamp(value, target, ref _velocity, smoothTime, maxSpeed, deltaTime);
32+
value = Vector3.SmoothDamp(value, target, ref m_Velocity, smoothTime, maxSpeed, deltaTime);
3333
return value;
3434
}
3535

0 commit comments

Comments
 (0)