| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | public class StickerAnimationListener : MonoBehaviour |
| | 4 | | { |
| | 5 | | private const float WEIGHT_THRESHOLD = 0.5f; |
| | 6 | | private StickersController stickersController; |
| | 7 | |
|
| 0 | 8 | | private void Awake() { stickersController = GetComponentInParent<StickersController>(); } |
| | 9 | |
|
| | 10 | | //It's going to be called through an AnimationEvent |
| | 11 | | private void PlaySticker(AnimationEvent animEvent) |
| | 12 | | { |
| 0 | 13 | | if (string.IsNullOrEmpty(animEvent.stringParameter)) |
| 0 | 14 | | return; |
| | 15 | |
|
| 0 | 16 | | if (animEvent.animationState.weight < WEIGHT_THRESHOLD) |
| 0 | 17 | | return; |
| | 18 | |
|
| 0 | 19 | | stickersController?.PlaySticker(animEvent.stringParameter); |
| 0 | 20 | | } |
| | 21 | | } |