com.wallstop-studios.unity-helpers 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ namespace WallstopStudios.UnityHelpers.Tags
48
48
  /// </summary>
49
49
  public event Action<string, float, float> OnAttributeModified;
50
50
 
51
- private readonly Dictionary<string, Func<object, Attribute>> _attributeFieldGetters;
51
+ private Dictionary<string, Func<object, Attribute>> _attributeFieldGetters;
52
52
  private readonly HashSet<EffectHandle> _effectHandles;
53
53
 
54
54
  [SiblingComponent]
@@ -62,7 +62,6 @@ namespace WallstopStudios.UnityHelpers.Tags
62
62
  /// </summary>
63
63
  protected AttributesComponent()
64
64
  {
65
- _attributeFieldGetters = AttributeUtilities.GetOptimizedAttributeFields(GetType());
66
65
  _effectHandles = new HashSet<EffectHandle>();
67
66
  }
68
67
 
@@ -72,6 +71,7 @@ namespace WallstopStudios.UnityHelpers.Tags
72
71
  /// </summary>
73
72
  protected virtual void Awake()
74
73
  {
74
+ EnsureAttributeFieldGettersInitialized();
75
75
  this.AssignSiblingComponents();
76
76
  _effectHandler.Register(this);
77
77
  }
@@ -217,8 +217,9 @@ namespace WallstopStudios.UnityHelpers.Tags
217
217
  }
218
218
  }
219
219
 
220
- private bool TryGetAttribute(string attributeName, out Attribute attribute)
220
+ protected bool TryGetAttribute(string attributeName, out Attribute attribute)
221
221
  {
222
+ EnsureAttributeFieldGettersInitialized();
222
223
  if (
223
224
  !_attributeFieldGetters.TryGetValue(
224
225
  attributeName,
@@ -233,5 +234,15 @@ namespace WallstopStudios.UnityHelpers.Tags
233
234
  attribute = getter(this);
234
235
  return true;
235
236
  }
237
+
238
+ protected void EnsureAttributeFieldGettersInitialized()
239
+ {
240
+ if (_attributeFieldGetters != null)
241
+ {
242
+ return;
243
+ }
244
+
245
+ _attributeFieldGetters = AttributeUtilities.GetOptimizedAttributeFields(GetType());
246
+ }
236
247
  }
237
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},