Skip to content

Commit 55c772f

Browse files
committed
Don't cache serialized properties
1 parent 495cf6f commit 55c772f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

Editor/ShaderPropertyPropertyDrawer.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,20 @@ namespace Zigurous.Graphics.Editor
66
[CustomPropertyDrawer(typeof(ShaderProperty))]
77
public sealed class ShaderPropertyPropertyDrawer : PropertyDrawer
88
{
9-
private SerializedProperty _name;
10-
private SerializedProperty _id;
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 (_id == null) {
19-
_id = property.FindPropertyRelative("_id");
20-
}
11+
SerializedProperty name = property.FindPropertyRelative("_name");
12+
SerializedProperty id = property.FindPropertyRelative("_id");
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 value = EditorGUI.TextField(position, name.stringValue);
2618

27-
if (name != _name.stringValue)
19+
if (value != name.stringValue)
2820
{
29-
_name.stringValue = name;
30-
_id.intValue = Shader.PropertyToID(name);
21+
name.stringValue = value;
22+
id.intValue = Shader.PropertyToID(value);
3123
}
3224

3325
EditorGUI.EndProperty();

0 commit comments

Comments
 (0)