SpritedowAnimator icon indicating copy to clipboard operation
SpritedowAnimator copied to clipboard

Check if customEvents is null before accessing

Open RobbyZ opened this issue 2 years ago • 0 comments

Thanks for this great resource :)

I found a small bug. I am checking events first before adding them to ensure I don't double-add a custom event. But if I do this, I'll get a null reference exception because customEvents is null until one is defined.

https://github.com/Elendow/SpritedowAnimator/blob/d3cb7a4729db5dd03e18abb093c13a8f6becf8b8/Source/Assets/SpritedowAnimator/Source/BaseAnimator.cs#L686

I added a null check to this if:

if (customEvents != null && customEvents.ContainsKey(eventInfo))

But maybe would be better to just always define customEvents on init? If not, there may be some other places where customEvents is accessed without null check.

RobbyZ avatar Apr 01 '22 03:04 RobbyZ